Help with referral system errors!!!!

Results 1 to 6 of 6
  1. #1
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    angry Help with referral system errors!!!!

    Hi,
    Im fixing up an automatic referral system but am stuck on one thing which ive been trying to fix for days now.

    So the code is:

    if(!empty($_SESSION['refer'])){
    $execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
    }
    header("LOCATION: ". PATH ."/me.php");
    return true;

    The bit I highlighted in red is the problem, I forced PHP to display errors and the following errors displayed:

    Notice: Undefined variable: db in C:\xampp\htdocs\inc\functions.php on line 438

    Fatal error: Call to a member function query() on null in C:\xampp\htdocs\inc\functions.php on line 438

    If you can help me fix this error I would greatly appreciate it, Thank You!!!!

    - - - Updated - - -

    Someone please help me ASAP!!!!


  2. #2
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Help with referral system errors!!!!

    Quote Originally Posted by Habbz96 View Post
    Hi,
    Im fixing up an automatic referral system but am stuck on one thing which ive been trying to fix for days now.

    So the code is:

    if(!empty($_SESSION['refer'])){
    $execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
    }
    header("LOCATION: ". PATH ."/me.php");
    return true;

    The bit I highlighted in red is the problem, I forced PHP to display errors and the following errors displayed:

    Notice: Undefined variable: db in C:\xampp\htdocs\inc\functions.php on line 438

    Fatal error: Call to a member function query() on null in C:\xampp\htdocs\inc\functions.php on line 438

    If you can help me fix this error I would greatly appreciate it, Thank You!!!!

    - - - Updated - - -

    Someone please help me ASAP!!!!
    Sorry, I've been out for a while, can you pastebin the functions.php again?

  3. #3
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Help with referral system errors!!!!


  4. #4
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Help with referral system errors!!!!

    Quote Originally Posted by Habbz96 View Post
    This might be your lucky day amigo!

    Replace this (Lines 437- 439)

    PHP Code:
    if(!empty($_SESSION['refer'])){                                                $execute $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");                                        } 
    To this:

    PHP Code:
    if(!empty($_SESSION['refer'])){
    global 
    $db;
    $execute=$db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");

    Best of luck!

  5. #5
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Help with referral system errors!!!!

    OMG, THANK YOU SO MUCH IT WORKS, I CANT THANK YOU ENOUGH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU,

  6. #6
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Help with referral system errors!!!!

    Quote Originally Posted by Habbz96 View Post
    OMG, THANK YOU SO MUCH IT WORKS, I CANT THANK YOU ENOUGH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU,
    It's only a matter of identifying the error haha

    Have an awesome time, cheers



Advertisement