Jump to content

Recommended Posts

Can anyone see where the error in this code is:

foreach($food_categories as $key => $subarray)
{
echo "<h3>$key</h3>";
echo "<ul>";
foreach($subarray as $type)
{
echo "<input type='radio' name='interest'
value='$type'><b><img src="$type" width=100 height=100></b> [b](line 28)[/b]
<br>\n";
}
echo "</ul>";
}

The debugger is showing:

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\Project\htdocs\catalogAccessories.inc on line [b]28[/b]
Link to comment
https://forums.phpfreaks.com/topic/5283-error-in-code/
Share on other sites

[!--quoteo(post=356395:date=Mar 19 2006, 12:02 PM:name=OriginalSunny)--][div class=\'quotetop\']QUOTE(OriginalSunny @ Mar 19 2006, 12:02 PM) [snapback]356395[/snapback][/div][div class=\'quotemain\'][!--quotec--]
<b><img src="$type" width=100 height=100></b>
[/quote]

should be either \"$type\" or '$type', plus i'd recommend putting your width and height tags with ' or \" too.
Link to comment
https://forums.phpfreaks.com/topic/5283-error-in-code/#findComment-18791
Share on other sites

sure... where you're assigning your src, you're closing and reopening your string (double quotes) around your variable without concatonating. you need to do one of three things to fix it:

1) concatonate the string:
[code]
echo "<input type='radio' name='interest'
value='$type'><b><img src=" . $type . " width='100' height='100'></b>
<br>\n";
[/code]

2) escape the double quotes:
[code]
echo "<input type='radio' name='interest'
value='$type'><b><img src=\"$type\" width='100' height='100'></b>
<br>\n";
[/code]

3) use single quotes:
[code]
echo "<input type='radio' name='interest'
value='$type'><b><img src='$type' width='100' height='100'></b>
<br>\n";
[/code]

good luck
Link to comment
https://forums.phpfreaks.com/topic/5283-error-in-code/#findComment-18793
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.