<?php
$conn = mysql_connect("localhost", "root", "general");
mysql_select_db("cms");
$result = mysql_query("SELECT * FROM Category");
echo "<table width='400' border='1' cellpadding ='3' cellspacing ='4' bordercolor='#45310F' fontcolor=#FFFFFF>";


//$cimage =
while($take = mysql_fetch_array($result))
{
echo"<tr><tr>";
echo "<tr><td>";
print $take."<br>";
echo "</td><td>";
print $take."<br>";
echo "</td></td>";
echo "<t6><td>";
echo  $take."<br>";
echo "</td></tr></tr>";
echo "<tr><tr>";
}
echo "</font>";
echo "</table>";
echo "<br><br><br>";
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

Recommended Answers

All 11 Replies

echo <img src=$take>.
put it inside the image...

thanks...
will try and let know how it wrks..

i tried through it ..but i get an error...
Parse error: syntax error, unexpected '<' in ....

echo "<img src='.$take.'>";

put necessary quotes to display image.

oops!I also made the wrong concatenation. try this one if the latter produces the same error.

echo "<img src=' ".$take." '>";

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.

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...?

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)

Member Avatar for fatihpiristine

i think the reason is file extensions...

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)

Is the column type where u store the path to the image VARCHAR?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.