Insert some code into template

Started by gregy, September 24, 2008, 12:04:18 PM

Previous topic - Next topic

gregy

Hi guys

I would like to add some code that will collect some statistic, but i keep getting error.

Code is;
<script type="text/javascript">
<!--
var r = Math.random();
var t = new Date();
document.write("<img width='1' height='1' src='http://domain.com/nc/px.gif?site=name&t=" + t.getTime() + ";r=" + r + "'>");
// -->
</script>
<noscript>
<img width="1" height="1" src="http://domain.com/nc/px.gif?site=name&js=0">
</noscript>


The code above generates error
QuoteTemplate Parse Error!
There was a problem loading the /Themes/default/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.

Thank you for your help

ccbtimewiz

Single quotes need to be escaped.

Do it like this:

echo '
<script type="text/javascript">
<!--
var r = Math.random();
var t = new Date();
document.write("<img width=\'1\' height=\'1\' src=\'http://domain.com/nc/px.gif?site=name&t=" + t.getTime() + ";r=" + r + "\'>");
// -->
</script>
<noscript>
<img width="1" height="1" src="http://domain.com/nc/px.gif?site=name&js=0" alt="*" />
</noscript>';

gregy


Advertisement: