Click here to Skip to main content
14,699,428 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm creating a login/register system and I got this error
Fatal error: Call to a member function passed() on a non-object in D:\ProgramFile\Xampp\htdocs\site\shop\register.php on line 28
my code is[^][^]

Thank you in advance.
P.S. Sorry if I'm noob I'm very new to OOP/PDO.
Richard MacCutchan 23-Nov-14 7:34am
Please show the actual code where the error occurs, rather than links to pictures.
Sergey Alexandrovich Kryukov 23-Nov-14 14:10pm
In what line? Why not posting your code on this page?
The problem is very simple, you just need to fix some bug...
Theminer3746 23-Nov-14 21:21pm
The error occurred when I call $validation->passed() which will return $this->_passed;

1 solution

There seem not to be anything wrong with the codes you posted. The bug meant be hidden somewhere else probably in your class config, because this is the only code that will run when you call ->passed().
private function __construct(){
        try {
            $this->_pdo = new PDO(
            'mysql:host=' . config::get('mysql/host'),//get host name
            'dbname=' . config::get('mysql/db'),//get database name
        } catch (PDOException $e){
Theminer3746 25-Nov-14 20:52pm
Thanks for help I just got the passes() method to work. But after that I call
$this->_query = $this->_pdo->prepare($sql)
which create the Fatal error: Call to a member function prepare() on a non-object.
So my question is now why $this->_pdo is not callable?
Oso Oluwafemi Ebenezer 26-Nov-14 2:12am
If you are still using the code you posted earlier, what did you expect? class Validate as no method _pdo (you are using $this on it, see?). But I doubt you are still using the code anyway, because I can't figure out where the ->prepare came from.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900