OriginalSunny Posted March 19, 2006 Share Posted March 19, 2006 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] Quote Link to comment Share on other sites More sharing options...
tjhilder Posted March 19, 2006 Share Posted March 19, 2006 [!--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. Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 19, 2006 Share Posted March 19, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.