tom232 Posted January 3, 2007 Share Posted January 3, 2007 THE CODE $result = $conn->query(" select * from user where username='$username' "); and $result = $conn->query("insert into user values ('$username', sha1('$password'), '$email')");ERROR (same error)Fatal error: Call to a member function query() on a non-object in /home/u7/collegenote/html/logtest/user_auth_fns.php on line 14what am im missing? this has been driving me crazy Quote Link to comment https://forums.phpfreaks.com/topic/32645-solved-query-help/ Share on other sites More sharing options...
tom232 Posted January 3, 2007 Author Share Posted January 3, 2007 Heres the code[code]<?phprequire_once('db_fns.php');function register($username, $email, $password)// register new person with db// return true or error message{ // connect to db $conn = mysql_connect(localhost, collegenote, OC1kl07r); // check if username is unique $result = $conn->query(" select * from user where username='$username' "); if (!$result) throw new Exception('Could not execute query'); if ($result->num_rows>0) throw new Exception('That username is taken - go back and choose another one.'); // if ok, put in db $result = $conn->query("insert into user values ('$username', sha1('$password'), '$email')"); if (!$result) throw new Exception('Could not register you in database - please try again later.'); return true;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32645-solved-query-help/#findComment-151895 Share on other sites More sharing options...
Jessica Posted January 3, 2007 Share Posted January 3, 2007 It says $conn is not an object. mysql_connect returns a resource. It's not an object that you call a method on, it's a resource you use in a function like http://us2.php.net/mysql_query Quote Link to comment https://forums.phpfreaks.com/topic/32645-solved-query-help/#findComment-151898 Share on other sites More sharing options...
tom232 Posted January 3, 2007 Author Share Posted January 3, 2007 so what do i need to define it as? Quote Link to comment https://forums.phpfreaks.com/topic/32645-solved-query-help/#findComment-151908 Share on other sites More sharing options...
corbin Posted January 3, 2007 Share Posted January 3, 2007 Ummm instead of $conn->query(You need to use mysql_query( Quote Link to comment https://forums.phpfreaks.com/topic/32645-solved-query-help/#findComment-151911 Share on other sites More sharing options...
tom232 Posted January 3, 2007 Author Share Posted January 3, 2007 ok thanks Quote Link to comment https://forums.phpfreaks.com/topic/32645-solved-query-help/#findComment-151915 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.