1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to solve these errors in WAMP

Discussion in 'PHP' started by iamshahz, Nov 23, 2012.

  1. #1
    hi can someone tell me how to fix these errors in wamp local server,
    please see attached screenshot
     

    Attached Files:

    iamshahz, Nov 23, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Since you don't show us the code, this is only a guess, but in PHP you can't use a variable before it's defined. A construct like

    $x = $x . 'something';

    will produce that error, since you're adding to the variable $s before you define it. (It's on the right side before it's defined in a previous line.)

    $x .= 'something';

    will produce the same error. So will

    $x = $x + 6;

    So look for any place you've used a variable on the right side of the equal sign before defining it in a previous line.

    It also sometimes happens where you define a global variable (define it outside a function), then forget to declare it as a global inside a function.
     
    Rukbat, Nov 23, 2012 IP
  3. iamshahz

    iamshahz Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    here is source code.errors in line 21, 23, 25, 27, 27, 28, 28


    <?php
    function formatemail($body,$uid,$sitepath)
    {
    $udetails = mysql_fetch_array(mysql_query("select * from en_users where id_users=$uid"));
    $body = str_replace('[Name]',$udetails['name'],$body);
    $body = str_replace('[Activation Link]',$sitepath."?p=Activation&actcode=".urlencode(base64_encode($udetails['actcode'])),$body);
    $body = str_replace('[Username]',$udetails['email'],$body);
    $body = str_replace('',$udetails['email'],$body);
    $body = str_replace('[Password]',$udetails['password'],$body);

    return $body;
    }
    if(isset($_REQUEST['logout']))
    {
    session_unset($_SESSION['evausername']);
    session_unset($_SESSION['uid']);
    session_unset($_SESSION['name']);
    }


    $date = date('Y-m-d');
    if(mysql_num_rows(mysql_query("select * from k4g_visitorslist where cdate='$date' and ip='$ip'")) == 0)
    {
    mysql_query("insert into k4g_visitorslist set cdate='$date',ip='$ip'");
    }
    if($country != 'This record is unavailable in demo version. Please subscribe.')
    {
    if(mysql_num_rows(mysql_query("select * from k4g_visitorslist where region='$country' and cdate=NOW() and ip='$ip'")) == 0)
    mysql_query("insert into k4g_visitorslist set region='$country',cdate=NOW(),ip='$ip'");
    }
    if(!isset($_SESSION['onlineusers']))
    {
    //echo "here====";
    $_SESSION['onlineusers'] = 1; $dt = date('Y-m-d');
    if(mysql_num_rows(mysql_query("select * from k4g_stats where `date`='$dt'")) == 0)
    {
    mysql_query("insert into k4g_stats set `date`='$dt', guest=1");
    //echo "insert into k4g_stats set `date`='$dt', guest=1";
    }
    else
    {
    mysql_query("update k4g_stats set guest=guest+1 where `date`='$dt'");
    //echo "update k4g_stats set guest=guest+1 where `date`='$dt'";
    }
    }


    ?>
     
    iamshahz, Nov 23, 2012 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    As the errors themselves say, you aren't defining $ip or $country anywhere.
     
    Rukbat, Nov 23, 2012 IP