Forum Moderators: coopster

Message Too Old, No Replies

parse error, unexpected T_STRING, expecting ',' or ';' in

         

rj24

3:27 am on Jan 30, 2006 (gmt 0)

10+ Year Member



Hello, I receive the following message when I try to replace a google adsense javascript with phpadsnew javascript.

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/oghq/public_html/plugins/site/themes/21/game.php on line 131

Below is the relevant code.


<tr>
<td width='100%' colspan='2' valign='top'>
<div class='ocontentsection'>
<div class='ocontenthead'>Similar Games</div>
<div class='contenttext'> <?php echo "<table width='97%' class='contenttable'><tr>";

echo "<td width='50%' valign='top' align='left'>"; echo "<div style='padding-bottom: 4px;'><b>If you liked
".$game['name'].", you may also enjoy...</b></div>"; $q = "SELECT * FROM games WHERE cat='".$game['cat']."' AND
id!='".$game['id']."' ORDER BY RAND() DESC LIMIT 0, ".$themecfg['similargamesnumber'].""; $games2 =
get_games("shortdesc=".$themecfg['maxdesclength']."&htmlize=true&diffquery=".$q); foreach ($games2 as $game2) {
$link = get_game_link("id="._sp($game2['id']));
echo "<table class='gltable' cellpadding='0' cellspacing='0'><tr><td><a href='".$link."'
class='gamelink'><img src='[imgdir]".$game2['nameid'].".png' alt='".$game2['name']."' width='[twidth]'
height='[theight]' class='gamethumb' align='left' /></a>
<a href='".$link."' class='gamelink'>".$game2['name']."</a><br />
".$game2['desc']."</td></tr></table>";
}
echo '</td>
<td width=50% valign=top align=right>
<script language='JavaScript' type='text/javascript' src='http://www.example.com/adserver/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.example.com/adserver/adjs.php?n=" + phpAds_random);
document.write ("&amp;what=zone:1");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.example.com/adserver/adclick.php?n=a4022dc3' target='_blank'><img src='http://www.example.com/adserver/adview.php?what=zone:1&amp;n=a4022dc3' border='0' alt=''></a></noscript></td>
</tr></table>';?>
</div>
</div>
</div>
</td> </tr>

If anyone has any advice on how to address this situation I would greatly appreciate it.

[edited by: coopster at 2:48 pm (utc) on Jan. 30, 2006]
[edit reason] generalized url per TOS [webmasterworld.com] [/edit]

aaron_d

3:49 am on Jan 30, 2006 (gmt 0)

10+ Year Member



You opened your second echo with a ' and then used them inside as part of the printed code. If you open the echo with a ' or a " then you must escape all instances of the same inside the echo with a backslash.

rj24

6:22 am on Jan 30, 2006 (gmt 0)

10+ Year Member



Thank you for your advice. I am just learning PHP, so your help is greatly appreciated.

I tried to implement your suggestions, but did not have any luck. Would you be able to give me an example?

aaron_d

8:27 am on Jan 30, 2006 (gmt 0)

10+ Year Member




echo '</td>
<td width=50% valign=top align=right>
<script language='JavaScript' type='text/javascript' src='http://www.example.com/adserver/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.example.com/adserver/adjs.php?n=" + phpAds_random);
document.write ("&amp;what=zone:1");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.example.com/adserver/adclick.php?n=a4022dc3' target='_blank'><img src='http://www.example.com/adserver/adview.php?what=zone:1&amp;n=a4022dc3' border='0' alt=''></a></noscript></td>
</tr></table>';

Would be better as:


print <<<block
</td>
<td width=50% valign=top align=right>
<script language='JavaScript' type='text/javascript' src='http://www.example.com/adserver/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.example.com/adserver/adjs.php?n=" + phpAds_random);
document.write ("&amp;what=zone:1");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.example.com/adserver/adclick.php?n=a4022dc3' target='_blank'><img src='http://www.example.com/adserver/adview.php?what=zone:1&amp;n=a4022dc3' border='0' alt=''></a></noscript></td>
</tr></table>
block;

If that doesn't work there could be other errors.

(This post should have been moved to php not javascript)

<right you are -- it's now moved>

[edited by: tedster at 8:47 am (utc) on Jan. 30, 2006]

[edited by: coopster at 2:50 pm (utc) on Jan. 30, 2006]
[edit reason] generalized url [/edit]