Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.