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 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] 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 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? 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( 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 Link to comment https://forums.phpfreaks.com/topic/32645-solved-query-help/#findComment-151915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.