Jump to content

Archived

This topic is now archived and is closed to further replies.

OriginalSunny

Error in code??

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]

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.