Jump to content

[SOLVED] picture from mysql text


tml

Recommended Posts

hi i cant get my picture from my database,

my picture are uploaded at billed/1.jpg

and my database have the text in it as billed/1.jpg under id 1

 

its connected

 

 

here's my code

 

$query = mysql_query("SELECT * FROM billed");

while($row = mysql_fetch_assoc($query))

{

    echo <img scr="$row["id"]" . " class="foto"/>"<br/>";

}

?>

 

 

can u tell me whats wrong?

Link to comment
https://forums.phpfreaks.com/topic/126737-solved-picture-from-mysql-text/
Share on other sites

You're echo is incorrect. Take a look.

 

Firstly, you are not opening with any quotes.

 

echo "<img scr="$row["id"]" . " class="foto"/>"";

 

Second, you have scr not src.

 

echo "<img src="$row["id"]" . " class="foto"/>"";

 

Third, you use double quotes again after the =. You cannot do this, because PHP will get confused. You can do it if you escape the quotes with a backslash or you can use single quotes. Or you can break out, which is what it looks like you tried to do. So we'll break out.

 

echo "<img src='" . $row["id"] . "' class="foto"/>"";

 

Notice how I've used single quotes, then broken out with the double quotes so we can use the array variable.

Then I've gone back into the echo and we come to class. Again Instead of double quotes use single quotes.

 

echo "<img src='" . $row["id"] . "' class='foto' />"";

 

Then at the end you have two double quotes, not needed. Simply remove one.

 

echo "<img src='" . $row["id"] . "' class='foto' />";

 

Lastly, ensure that the $row['id'] is actually the proper address to the image and that you do not need to add anything.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.