how to make this code work in php

matrixweb

Expert Member
Joined
Apr 7, 2008
Messages
1,210
Reaction score
0
Location
Durban
<script type="text/javascript"><!--
document.write('<s'+'cript type="text/javascript" src="http://cpm-traffic.com/show.php?z=1&pl=4426&j=1&code='+new Date().getTime()+'"></s'+'cript>');
// --></script>
<noscript>
<iframe src="http://cpm-traffic.com/show.php?z=1&pl=4426" width="468" height="60" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
</noscript>

everytime i paste it i get a error
 
I'm no expert at Javascript, but I would guess that your use of quotes is either incorrect, not escaped properly, or each opening one does not match up to a closing one.

Double check this first. A good editor with proper syntax highlighting will most often point this out to you. Also, try the JSlint and Javascript Lint tools.

My guess is that the quotes are not closed off properly, which is making your PHP code invalid - as it starts/ends at some weird place..

As a side note, I noticed that your first script block will look like this

<script><script>....</script></script>

Is this correct?
 
Last edited:
That code results in an advert - "We deliver signups" - on my Mac so somewhere it is working.

The syntax colouring does not like the /s' part. It is a lovely little problem though. Give me an hour...
 
In short, I have no idea...

Strictly speaking, the & should be &amp; even in URLs but generally that makes no difference. Also, I thought the / was causing the problems but when I changed it with / it stopped working. YMMV.

This PHP code works...
Code:
<?php
$gettime = microtime(true)*1000;
echo ('<SCRIPT TYPE="text/javascript" SRC="http://cpm-traffic.com/show.php?z=1&amp;pl=4426&amp;j=1&amp;code='.$gettime.'"></SCRIPT>');
?>

...but this Javascript does not, for reasons still unknown:
Code:
<script type="text/javascript"><!--
document.write('<s'+'cript type="text/javascript" src="http://cpm-traffic.com/show.php?z=1&amp;pl=4426&amp;j=1&amp;code='+new Date().getTime()+'"></s'+'cript>'); 
// --></script>
<noscript>
<iframe src="http://cpm-traffic.com/show.php?z=1&amp;pl=4426" width="468" height="60" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
</noscript>
 
Wow - quick note: the / were replace with the ampersand escape: ampersand#47; but they came up as / in the above...
 
Top
Sign up to the MyBroadband newsletter
X