how to make this code work in php

matrixweb

Expert Member
Joined
Apr 7, 2008
Messages
1,210
<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
 

Saajid

Expert Member
Joined
Aug 8, 2008
Messages
4,559
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:

GreGorGy

BULLSFAN
Joined
Jan 18, 2005
Messages
15,289
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...
 

Saajid

Expert Member
Joined
Aug 8, 2008
Messages
4,559
Please post back when you've solved it. I'm interested to know what was wrong...
 

GreGorGy

BULLSFAN
Joined
Jan 18, 2005
Messages
15,289
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>
 

GreGorGy

BULLSFAN
Joined
Jan 18, 2005
Messages
15,289
Wow - quick note: the / were replace with the ampersand escape: ampersand#47; but they came up as / in the above...
 
Top