raytri Posted February 22, 2009 Share Posted February 22, 2009 Hi. I'm a new member and pretty new to PHP. My apologies if this question has been answered a hundred times before: When I write the following code: echo '<tr><td><a href="javascript:PopupPic(\'../images/popups/landscapes/'$BigImage'\')"><img src="../images/landscapes/'$Image'" class="gallery" alt="'$Title'" /></a><br /><p class="title">'$Title'</p><p class="description">'$Width'” x '$Height'”</p><p class="sold">'$IsItSold'</p></td>'; I get the following error: Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' I can't spot the problem. I think I've properly escaped the single quotes in the echoed portion, and there's no missing bracket errors that I know of. For what it's worth, here's the full code section. Note that the "elseif" and "else" echos are enclosed in double quotes (with double quotes escaped) rather than single quotes; I'm trying to fix the above coding problem before changing them. while ($myrow = mysql_fetch_array ($result)) { if ($column == 1)// first column display { echo '<tr><td><a href="javascript:PopupPic(\'../images/popups/landscapes/'$BigImage'\')"><img src="../images/landscapes/'$Image'" class="gallery" alt="'$Title'" /></a><br /><p class="title">'$Title'</p><p class="description">'$Width'” x '$Height'”</p><p class="sold">'$IsItSold'</p></td>'; $column=2; } elseif ($column == 2)// second column display { echo "<td><a href=\"javascript:PopupPic('../images/popups/landscapes/"$BigImage"')\"><img src=\"../images/landscapes/"$Image"\" class=\"gallery\" alt=\""$Title"\" /></a><br /> <p class=\"title\">"$Title"</p> <p class=\"description\">"$Width"” x "$Height"”</p> <p class=\"sold\">"$IsItSold"</p> </td>"; $column=3; } else// third column display { echo "<td><a href=\"javascript:PopupPic('../images/popups/landscapes/"$BigImage"')\"><img src=\"../images/landscapes/"$Image"\" class=\"gallery\" alt=\""$Title"\" /></a><br /> <p class=\"title\">"$Title"</p> <p class=\"description\">"$Width"” x "$Height"”</p> <p class=\"sold\">"$IsItSold"</p> </td></tr>"; $column=1; } $count += 1; } Thanks for any help you can give a newbie. Quote Link to comment Share on other sites More sharing options...
jeger003 Posted February 22, 2009 Share Posted February 22, 2009 anytime you echo html you need to change " (double quotes) to ' (single qoute) because echo begins and ends with double quotes............so just change all double qoutes in echo "your html"; to single qoutes and see if that works Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 22, 2009 Share Posted February 22, 2009 Proper code highlighting... echo '<tr><td><a href="javascript:PopupPic(\'../images/popups/landscapes/'$BigImage'\')"><img src="../images/landscapes/'$Image'" class="gallery" alt="'$Title'" /></a><br /><p class="title">'$Title'</p><p class="description">'$Width'” x '$Height'”</p><p class="sold">'$IsItSold'</p></td>'; and we see our culprits (in blue). To join strings together use concatenation operator (.) echo 'something'.$variable.'something else'; You can also use double quotes echo "something $variable something else"; Quote Link to comment Share on other sites More sharing options...
raytri Posted February 22, 2009 Author Share Posted February 22, 2009 Thanks, mchl. The periods did the trick. Now if I can just get my php variable names to match the field names pulled out of the database.... 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.