iAaron Posted May 22, 2007 Share Posted May 22, 2007 Anyone have any idea why I am getting this error... Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/coarsefi/public_html/bread.php on line 56 <?php $mems = "SELECT image FROM bait WHERE name = bread"; $mems = mysql_query($mems); $cnt = mysql_num_rows($mems); for ($i = 0; $i < $cnt && $rows = mysql_fetch_assoc($mems); $i++) { echo '<img border="0" scr="$rows['image']'.'">'.'<br/>'; } ?> Thanks... Link to comment https://forums.phpfreaks.com/topic/52527-solved-need-some-help/ Share on other sites More sharing options...
chigley Posted May 22, 2007 Share Posted May 22, 2007 <?php $mems = "SELECT image FROM bait WHERE name = 'bread'"; $mems = mysql_query($mems) or die(mysql_error()); while($row = mysql_fetch_assoc($mems)) { echo "<img border=\"0\" src=\"$row[image]\" alt=\"\" /><br />"; } ?> Neatened it up a little for you Link to comment https://forums.phpfreaks.com/topic/52527-solved-need-some-help/#findComment-259186 Share on other sites More sharing options...
AJReading Posted May 22, 2007 Share Posted May 22, 2007 I would go one step further and use the following: <?php $mems = "SELECT image FROM bait WHERE name='bread'"; $mems = mysql_query($mems) or die(mysql_error()); while($row = mysql_fetch_assoc($mems)) { echo '<img border="0" src="'.$row['image'].'" alt="" /><br />'; } ?> Should work the same but i perfer to clearly split my variable in echo statments. As chigley pointed out you need them quotes around the word name='bread' in your mysql query. You should always use them unless its a number Link to comment https://forums.phpfreaks.com/topic/52527-solved-need-some-help/#findComment-259198 Share on other sites More sharing options...
chigley Posted May 22, 2007 Share Posted May 22, 2007 For some bizarre reason I can't stand single quotes! Doubles rule Link to comment https://forums.phpfreaks.com/topic/52527-solved-need-some-help/#findComment-259201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.