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!!!!
Re: Help with referral system errors!!!!
Quote:
Originally Posted by
Habbz96
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?
Re: Help with referral system errors!!!!
Re: Help with referral system errors!!!!
Quote:
Originally Posted by
Habbz96
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!
Re: Help with referral system errors!!!!
OMG, THANK YOU SO MUCH IT WORKS, I CANT THANK YOU ENOUGH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
:thumbup::kiss: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,
Re: Help with referral system errors!!!!
Quote:
Originally Posted by
Habbz96
OMG, THANK YOU SO MUCH IT WORKS, I CANT THANK YOU ENOUGH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
:thumbup::kiss: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 :thumbup: