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 Link to comment https://forums.phpfreaks.com/topic/11762-error/ 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--] Link to comment https://forums.phpfreaks.com/topic/11762-error/#findComment-44503 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? Link to comment https://forums.phpfreaks.com/topic/11762-error/#findComment-44508 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--] Link to comment https://forums.phpfreaks.com/topic/11762-error/#findComment-44512 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 Link to comment https://forums.phpfreaks.com/topic/11762-error/#findComment-44515 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--] Link to comment https://forums.phpfreaks.com/topic/11762-error/#findComment-44517 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. Link to comment https://forums.phpfreaks.com/topic/11762-error/#findComment-44518 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--] Link to comment https://forums.phpfreaks.com/topic/11762-error/#findComment-44519 Share on other sites More sharing options...
newb Posted June 12, 2006 Author Share Posted June 12, 2006 yeah works, thanks ! :D Link to comment https://forums.phpfreaks.com/topic/11762-error/#findComment-44520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.