Hi , ive recently come to a stumbling block in my project in which displaying images has now become a problem .
My problem is when accessing a users page i want to display info about the said user and then have a profile picture.
The web pages for users is removed all unnecessary code to shorten it
<?php
require_once('auth.php');
require_once('config.php');
require_once('opendb.php');
session_start();
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
$user = $_SESSION['SESS_USERNAME'];
if(!$user)
{
echo "<br><p>Blah blah you arent logged in </p><br>";
}
else
{
//We need to grab the login name variable from the URL.
$user_id = clean($_REQUEST['user_id']);
$view_profile = mysql_query("SELECT * FROM members WHERE login = '$user_id'");
$user = mysql_fetch_array($view_profile);
$member_id= $user['member_id'];
$login = $user['login'];
$dob = $user['dob'];
$query = mysql_query("SELECT * FROM tbl_images WHERE id='$member_id'");
$row = mysql_fetch_array($query);
$content = $row['image'];
print ("member_id is : $member_id <BR>");
print ("UserName for login is : $login<BR>");
print ("Date of birth is : $dob<br>");
echo $content;
}
?>
Now when i run this page i recieve a page of the user details but the RAW data for the image ,
I heard adding header('Content-type: image/jpg'); would solve the problem but adding that just opens a page with the broken image icon .
At first i thought perhaps my image wasnt uploaded correctly so i added this page to test it
<?php
require_once('config.php');
require_once('opendb.php');
$storedid = "11";
$id = (int)$storedid;
if(!isset($id) || empty($id)){
die("Please select your image!");
}else{
$query = mysql_query("SELECT * FROM tbl_images WHERE id='$id'");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo $content;
}
?>
And the image displays correctly .
Not sure what im doing wrong but if you can give me any advice it'd be much appreciated.
Thanks ,
Pages.