Stickybomb Posted October 8, 2007 Share Posted October 8, 2007 hi i am working on my first really project using oop in php and have come across an error i do not under stand Fatal error: Call to a member function insertUser() on a non-object in /home/sticky/public_html/cms/inc/security.php on line 204 this is the function it is refernceing [code=php] function insertUser($user,$pass,$email,$sid,$time) { $sql = 'INSERT INTO users (user_pass, user_name, user_lvl, user_email, user_timestamp, user_sid, user_ip) VALUES ("'.$pass.'","'.addslashes($name).'","1",,"'.addslashes($email).'","'.$time.'","'.$sid.'","'.$_SERVER['REMOTE_ADDR'].'")'; $db->query($sql); } //add user function addUser() { $email = $this->value['email']; $sid = $this->value['sid']; $pass = $this->value['pass']; $user = $this->value['user']; $time = Security::generateTimestamp(); $q->insertUser($user,$pass,$email,$sid,$time); //<-----This is the line from the error switch(VALIDATION_METHOD) { case 0: $this->generateEmail(); break; case 1: $this->generateValidEmail(); break; case 2: $this->generateAdminValidEmail(); break; } } [/code] any help pls? Link to comment https://forums.phpfreaks.com/topic/72361-solved-help-new-to-oop/ Share on other sites More sharing options...
pocobueno1388 Posted October 8, 2007 Share Posted October 8, 2007 Your probably never initialized the $db variable as an object. You use it here $db->query($sql); Before that did you ever do this? $db = new db_class; Link to comment https://forums.phpfreaks.com/topic/72361-solved-help-new-to-oop/#findComment-364957 Share on other sites More sharing options...
Stickybomb Posted October 9, 2007 Author Share Posted October 9, 2007 yes, i even tried moving where i declared it and still got the same error. Link to comment https://forums.phpfreaks.com/topic/72361-solved-help-new-to-oop/#findComment-365349 Share on other sites More sharing options...
pocobueno1388 Posted October 9, 2007 Share Posted October 9, 2007 Oh I see now. This line $q->insertUser($user,$pass,$email,$sid,$time); probably isn't in scope (the $q) since it is inside the defining of a function. So maybe create your $q object right before that line. Link to comment https://forums.phpfreaks.com/topic/72361-solved-help-new-to-oop/#findComment-365396 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.