newb Posted June 12, 2006 Share Posted June 12, 2006 echo <a href=\"$row['link'].'\">$row['thumb'].'</a>;gives me Parse error: syntax error, unexpected '<', expecting ',' or ';' in /xxx/xxx/xx/xx/xx/thumbnail.php on line 23any idea how to fix Quote Link to comment Share on other sites More sharing options...
jeremywesselman Posted June 12, 2006 Share Posted June 12, 2006 You have your quotes messed up.[code]<?phpecho '<a href="' . $row['link'] . '">' . $row['thumb'] . '</a>';?>[/code][!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Quote Link to comment Share on other sites More sharing options...
newb Posted June 12, 2006 Author Share Posted June 12, 2006 worked, thanks. btw, how do you know where the quotes go and how to set em up properly? Quote Link to comment Share on other sites More sharing options...
jeremywesselman Posted June 12, 2006 Share Posted June 12, 2006 Ok. Single quotes and double quotes have a slight difference in PHP. There is more than one way to code your example. Code 1:[code]<?phpecho "<a href=\"$row['link']\">$row['thumb']</a>";?>[/code]Code 2:[code]<?phpecho '<a href="' . $row['link'] . '">' . $row['thumb'] . '</a>';?>[/code]When you use double quotes while echoing a string, you don't need to concatenate the string with your variables. You can just echo them within the string. But with this technique, you do need to escape other double quotes in the string with a backslash(\).If you use single quotes while echoing a string, you have to concatenate(.) the string together with the variables, as in Code 2.[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Quote Link to comment Share on other sites More sharing options...
newb Posted June 12, 2006 Author Share Posted June 12, 2006 i see. well i ran into another error. its different.[code] echo "' . $row['name'] . '" <br> <table border='0' width='100%' id='table1'> <tr>";[/code]it generated this error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in xx/x/xxx/x/xxx on line 12can anyone help fix pleaseeee Quote Link to comment Share on other sites More sharing options...
jeremywesselman Posted June 12, 2006 Share Posted June 12, 2006 [code]<?phpecho "$row['name'] <br> <table border='0' width='100%' id='table1'> <tr>";?>[/code]If you use double quotes to echo with, you DO NOT need to concatenate your variable into your string.[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Quote Link to comment Share on other sites More sharing options...
newb Posted June 12, 2006 Author Share Posted June 12, 2006 ah, i tried that, but then i got the exact same error as well. Quote Link to comment Share on other sites More sharing options...
jeremywesselman Posted June 12, 2006 Share Posted June 12, 2006 Try this:[code]<?phpecho $row['name'] . "<br><table border='0' width='100%' id='table1'><tr>";?>[/code][!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Quote Link to comment Share on other sites More sharing options...
newb Posted June 12, 2006 Author Share Posted June 12, 2006 yeah works, thanks ! :D 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.