• Resolved somosguatemala

    (@somosguatemala)


    i want to add this code to my simplepress forum

    [ Code edited with backticks. Moderator note: when sharing code examples, please wrap the code in backticks or use the code button. ]

    <script type="text/javascript">
    if (typeof(ord)=='undefined') ord=Math.floor(Math.random()*10000000000000000);
    if (typeof(tile)=='undefined') tile=1;
    document.write('<scr'+'ipt language="JavaScript" src="http://ad.doubleclick.net/adj/hola.somosguatemala/_default;sz=160x600;tile=' + (tile++) + ';ord='+ ord + '?" type="text/javascript"></scr' + 'ipt>');
    </script>

    so i did this to it but it doesnt work i get an error what should i do to have it show up?

    echo '<script type="text/javascript">
    if (typeof(ord)=='undefined') ord=Math.floor(Math.random()*10000000000000000);
    if (typeof(tile)=='undefined') tile=1;
    document.write('<scr'+'ipt language="JavaScript" src="http://ad.doubleclick.net/adj/hola.somosguatemala/_default;sz=160x600;tile=' + (tile++) + ';ord='+ ord + '?" type="text/javascript"></scr' + 'ipt>');
    </script>';

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m a noob but I didn’t think you could mix javascript into php.

    Would it work if you closed the php then put the javascript then opened the php again?

    ?>
    <script type="text/javascript">
    if (typeof(ord)=='undefined') ord=Math.floor(Math.random()*10000000000000000);
    if (typeof(tile)=='undefined') tile=1;
    document.write('<scr'+'ipt language="JavaScript" src="http://ad.doubleclick.net/adj/hola.somosguatemala/_default;sz=160x600;tile=' + (tile++) + ';ord='+ ord + '?" type="text/javascript"></scr' + 'ipt>');
    </script>
    <?php //continue with the rest of your php

    I’m not if that would work but it might be worth a try

    I think one problem is that you have enclosed the echo’ed string in single quotes and there are single quotes inside the string, e.g around ‘undefined’. Try this instead:

    echo '<script type="text/javascript">
    if (typeof(ord)==\'undefined\') ord=Math.floor(Math.random()*10000000000000000);
    if (typeof(tile)==\'undefined\') tile=1;
    document.write(\'<scr\'+\'ipt language="JavaScript" src="http://ad.doubleclick.net/adj/hola.somosguatemala/_default;sz=160x600;tile=\' + (tile++) + \';ord=\'+ ord + \'?" type="text/javascript"></scr\' + \'ipt>\');
    </script>';
    Thread Starter somosguatemala

    (@somosguatemala)

    awsome thanx!! that worked!!

    If your problem has been solved, please use the dropdown on the right to mark this topic ‘Resolved’ so that anyone else with this question can see that there is a solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to add this code in a php file?’ is closed to new replies.