How to retrieve images from database
<?php
$conn = mysql_connect("localhost", "root", "general");
mysql_select_db("cms");
$result = mysql_query("SELECT * FROM Category");
echo "";
//$cimage =
while($take = mysql_fetch_array($result))
{
echo"";
echo "";
print $take['cat_name']."
";
echo "";
print $take['cat_desc']."
";
echo "";
echo "";
echo $take['cat_image']."
";
echo "";
echo "";
}
echo "";
echo "";
echo "
";
mysql_close($conn);
?>
this is my code to get the images from the database...
i have uploaded the images...
but..when i tried to view it only the image name appears..the image doesnt appear...
The image name in the mysql is called cat_image
tryphy
Junior Poster in Training
79 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
thanks...
will try and let know how it wrks..
tryphy
Junior Poster in Training
79 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
i tried through it ..but i get an error...
Parse error: syntax error, unexpected '<' in ....
tryphy
Junior Poster in Training
79 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
The way I was thinking was to upload the image to the ftp and then INSERT the path to where the image is inside the database.
Then essentially you'd retrieve the path of the image from the database and insert it inside an img tag.
Hi....
venom rush....
Thanks for the suggestion...i will try that also...
But the echo one works...
i can see only the image tag...that is the box, but not the image....
when i upload the image...i upload into a folder ..
and also to mysql..
<?php
$query = "INSERT INTO category(cat_name, cat_desc, cat_image)" .
"VALUES('$cname', '$cdesc','$cimage')";
mysql_query($query,$link)
or die("Couldn't add data to add to \"Category\" table:
".mysql_error($link));
mysql_close($link);
?>
This is how I insert into mysql..
but still i cudnt able to see the image...
Did i made any wrong...?
tryphy
Junior Poster in Training
79 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
i have a problem with images on my server where the extension will change to uppercase when uploaded. some servers will not display the image if the extension in the database and the one in the folder are not the same.
also did you add the folder to the path. (/folder/image.jpg)
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194