how i can add a popup in this Code?!

Discussion in 'PHP' started by informationHell, Jul 6, 2008.

  1. #1
    hello,
    i want to add a popup ad to this code.. i will store the popup ad code in ads.php and i want to include ads.php in the following code..

    i have tried using <?php include("ads.php")?> and also require_once("config.php"); but it gave error that headers already sent..

    please help! :confused:

    if (isset($_GET['l'])) {          
             $link = $db->execute("SELECT * FROM links WHERE linkcode='{$_GET['l']}'");
             if (mysql_num_rows($link)>0) {
                 $link = mysql_fetch_array($link, MYSQL_ASSOC);             
                 $db->execute("UPDATE links SET visits=" . ++$link['visits'] . " WHERE linkcode='{$_GET['l']}'") ;
    		[B]header("Location: " . $link['linkurl']);[/B]
    exit;
         
             }
         }
    
    Code (markup):
     
    informationHell, Jul 6, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    You already have some output before sending the header.

    var_dump(headers_sent());

    You must send any headers before ANY output is sent.

    Dan

    P.s. $link = $db->execute("SELECT * FROM links WHERE linkcode='{$_GET['l']}'");

    OMG :O - Please tell me that class includes sanitization.
     
    Danltn, Jul 6, 2008 IP
  3. informationHell

    informationHell Peon

    Messages:
    931
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i am pming you the whole index.php file
     
    informationHell, Jul 6, 2008 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    Send me the other files too, one of those is sending output to the browser.

    Remember, if you are NOT outputting any HTML, you should NOT include the ending ?> tag.

    e.g.

    config.php:
    Correct:
    <?php
    
    define('NAME', 'Danltn');
    
    
    
    PHP:
    Incorrect:
    <?php
    
    define('NAME', 'Danltn');
    
    ?>
    
    
    PHP:
     
    Danltn, Jul 6, 2008 IP