clanstyles Posted October 18, 2007 Share Posted October 18, 2007 Why doesn't this work? I get Fatal error: Call to a member function query() on a non-object in /home/xxxxx/xxxxxxxxxxx/xxxxxxxxxxxx.com/includes/class.user.php on line 27 function checkLogin($username, $password) { $sql = new mysqlQuery(); $sql->mysqlQuery(); $sql = "select * from users where username='$username' and password='$password' LIMIT 1"; $results = $sql->query($sql) ? "true" : "false"; if($results) { $array = $sql->fetch_array($sql->link_id, $sql); $this->username = $username; $this->password = $password; $_SESSION['username'] = $username; $_SESSION['password'] = $password; } } I didn't include sql connection and a few other methods since they aren't needed. <?php class mysqlQuery { # Global Cvars # Database Information var $link_id = 0; var $query_id = 0; var $affected_rows = 0; # - Error Information var $error = ""; var $errno = 0; # End Global Cvars ############################# # Opens the connection. # Returns results id. function query($query_string) { // do query $this->query_id = @mysql_query($query_string,$this->link_id); //if screwed up if (!$this->query_id) $this->messanger_handler("Mysql Error"); return $this->affected_rows = @mysql_affected_rows(); } } Quote Link to comment https://forums.phpfreaks.com/topic/73731-function-call-help/ Share on other sites More sharing options...
teng84 Posted October 18, 2007 Share Posted October 18, 2007 function checkLogin($username, $password) { $sql = new mysqlQuery(); $sql->mysqlQuery(); $sql = "select * from users where username='$username' and password='$password' LIMIT 1"; $results = $sql->query($sql) ? "true" : "false"; that part of your code no include for that class note its inside the function $sql->mysqlQuery(); <--where is the function mysqlQuery Quote Link to comment https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372035 Share on other sites More sharing options...
clanstyles Posted October 18, 2007 Author Share Posted October 18, 2007 There is the include require_once("class.query.php"); is it. Its called mysqlQuery. mysqlQuery is the constructor being called. It connects you to the database. It has my sql info in there ct.. It works because I can login using that entire class then it trips out and pulls that when getting there info. Quote Link to comment https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372037 Share on other sites More sharing options...
teng84 Posted October 18, 2007 Share Posted October 18, 2007 i think i got it lol $sql = new mysqlQuery(); $sql->mysqlQuery(); $sql = "select * from users where username='$username' and password='$password' LIMIT 1"; $results = $sql->query($sql) ? "true" : "false"; <--ERROR FOR SURE you over right the value of $sql with that query first you define $sql as object then you do this $sql = "select * etc.... Quote Link to comment https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372038 Share on other sites More sharing options...
clanstyles Posted October 18, 2007 Author Share Posted October 18, 2007 o rofl thanks I got it lOL Quote Link to comment https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372039 Share on other sites More sharing options...
teng84 Posted October 18, 2007 Share Posted October 18, 2007 nah... just replace your var name lol $teng = "select * from users where username='$username' and password='$password' LIMIT 1"; Quote Link to comment https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372040 Share on other sites More sharing options...
teng84 Posted October 18, 2007 Share Posted October 18, 2007 ok mark this solved Quote Link to comment https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372041 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.