Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    undefine index error 'ref'

    <?php
    require_once ('database/database.inc.php');
    $myDb = new Db;
    include ('siteconfig.inc.php');
    require_once ('controls.inc.php');
    if(isset($_COOKIE["usReferrer"])){
    }else
    {
    setcookie("usReferrer",limpiar($_GET["ref"]),time()+7776000);
    }
    ?>

    ------------------------------------------------------

    in the above the error message is following

    undefined index 'ref'

    please help me

  • #2
    New Coder
    Join Date
    May 2007
    Location
    Manchester, UK
    Posts
    72
    Thanks
    0
    Thanked 2 Times in 2 Posts
    You need to check that $_GET["ref"] exists, with isset();

    PHP Code:
    <?php
    require_once ('database/database.inc.php');
    $myDb = new Db;
    include (
    'siteconfig.inc.php');
    require_once (
    'controls.inc.php');
    if(isset(
    $_COOKIE["usReferrer"])){
    } elseif(isset(
    $_GET["ref"]))
    {
        
    setcookie("usReferrer",limpiar($_GET["ref"]),time()+7776000);
    }
    ?>
    Every PHP programmer of any skill level should set error_reporting(E_ALL); at the top of their scripts or in their php.ini


  •  

    Tags for this Thread

    Posting Permissions

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