trying to insert image into database
Posted: Tue Jan 22, 2008 1:32 pm
i can upload an image and insert the information i want about it into a database, the problem is, im trying to insert the image itself into the database as a medium blob. im not sure what im doing wrong because when i echo the query and try selecting the image to view it after it has been inserted into the database, a bunch of funny looking symbols appear. is this the binary form of the image? how can i get around this? some of my code is below
$content = addslashes(fread(fopen($file,"r"), filesize($filetmpName)));
$query = "INSERT INTO $Images (Image_Name, Size, Image, Username, Type, URL) VALUES ('$filename', '$filesize', '$content', '$_SESSION[username]', '$filetype', '$URL')";
$result= MYSQL_QUERY($query);
echo $query;
$query = "SELECT Image, Type FROM $Images WHERE ImageId='11'";
$result= MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0, "Image");
<img src="http://www.xxxxxxx.com/imageAd.php?file=11">
$content = addslashes(fread(fopen($file,"r"), filesize($filetmpName)));
$query = "INSERT INTO $Images (Image_Name, Size, Image, Username, Type, URL) VALUES ('$filename', '$filesize', '$content', '$_SESSION[username]', '$filetype', '$URL')";
$result= MYSQL_QUERY($query);
echo $query;
$query = "SELECT Image, Type FROM $Images WHERE ImageId='11'";
$result= MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0, "Image");
<img src="http://www.xxxxxxx.com/imageAd.php?file=11">