WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to add this code in a php file? (5 posts)

  1. somosguatemala
    Member
    Posted 2 years ago #

    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>';
  2. bythegram
    Member
    Posted 2 years ago #

    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

  3. vtxyzzy
    Member
    Posted 2 years ago #

    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>';
  4. somosguatemala
    Member
    Posted 2 years ago #

    awsome thanx!! that worked!!

  5. vtxyzzy
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.