tml Posted October 2, 2008 Share Posted October 2, 2008 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 More sharing options...
JasonLewis Posted October 2, 2008 Share Posted October 2, 2008 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. Link to comment https://forums.phpfreaks.com/topic/126737-solved-picture-from-mysql-text/#findComment-655504 Share on other sites More sharing options...
waynew Posted October 2, 2008 Share Posted October 2, 2008 Anyway, you should really be uploading them to the filesystem and keeping track of them with the db. Link to comment https://forums.phpfreaks.com/topic/126737-solved-picture-from-mysql-text/#findComment-655508 Share on other sites More sharing options...
tml Posted October 2, 2008 Author Share Posted October 2, 2008 thx alot for that explanation did help alot Link to comment https://forums.phpfreaks.com/topic/126737-solved-picture-from-mysql-text/#findComment-655527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.