SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist Caesar's Avatar
    Join Date
    May 2000
    Location
    On some harddisk
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm trying to display a CPM ad half the time and the other half the time display the number 2. Therefore, I came up with the following code. However, the ad never ever displays. Can someone tell me what's wrong?

    Code:
    <html>
    <head></head>
    <body>
    <?php
    $number = rand(1, 10);
    if($number<5){
    echo "<!--- start of focusIN code --->";
    echo "<center>";
    echo "<script language=JavaScript>";
    echo "<!--";
    echo "var now = new Date();";
    echo "var uaid = now.getTime() % Math.floor(8640000 - Math.random()*1000);";
    echo "document.write('<iframe src='http://focusin.ads.targetnet.com/ad/id=kelvin&opt=hhj&cv=210&uid=' + uaid + '' height=60 width=468 frameborder=0 marginheight=0 marginwidth=0 scrolling=no>');";
    echo "document.write('<a href=http://focusin.ads.targetnet.com/ad/id=kelvin&opt=cij&cv=210&uid=' + uaid + '' target=_blank>');";
    echo "document.write('<img src=http://focusin.ads.targetnet.com/ad/id=kelvin&opt=hij&cv=210&uid=' + uaid + '' alt='Click here to visit our sponsor' width=468 height=60 border=0>');";
    echo "document.write('</a><br><font face=arial size=1><a href=http://www.focusin.com>focusIN Specialty Web Network</a></font></iframe>');";
    echo "//-->";
    echo "<script>";
    echo "<noscript>";
    echo "<iframe src=http://focusin.ads.targetnet.com/ad/id=kelvin&opt=hhn&cv=210&uid=1 height=60 width=468 frameborder=0 marginheight=0 marginwidth=0 scrolling=no>";
    echo "<a href=http://focusin.ads.targetnet.com/ad/id=kelvin&opt=cin&cv=210&uid=1 target=_blank><br>";
    echo "<img src=http://focusin.ads.targetnet.com/ad/id=kelvin&opt=hin&cv=210&uid=1 alt='Click here to visit our sponsor' width=468 height=60 border=0>";
    echo "</a><br><font face=arial size=1><a href=http://www.focusin.com>focusIN Specialty Web Network</a></font></iframe>";
    echo "</noscript>";
    echo "</center>";
    echo "<!------------ end of focusIN code ------------>";
    }
    else {
    echo "2";
    }
    ?>
    </body>
    </html>

  2. #2
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Any thoughts on how this can be made to work.

    I loaded it and it came up a blank screen. Not really sure what I should have seen.

    Anyone?

  3. #3
    SitePoint Zealot moshe_be's Avatar
    Join Date
    Dec 2000
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Before using rand you need to initialize it. the correct code:

    srand((double)microtime()*1000000);
    $number = rand(1,2);

    if($number == 1)
    {
    // Ad code #1
    } else {
    #ad code #2
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •