Jump to content

[SOLVED] Need some help...


iAaron

Recommended Posts

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

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

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

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.