wikedawsum Posted December 29, 2006 Share Posted December 29, 2006 Now that my <a href="http://www.phpfreaks.com/forums/index.php/topic,120298.0.html">other problem</a> was solved, I keep getting the "could not execute query" error when trying to register. I think the problem lies somewhere in my database connection, and user authentication files. The codes are listed below.db_fns.php (password has been removed)[code]<?phpfunction db_connect(){ $result = new mysqli('mysql.aacapartsandsupplies.com', 'admin', '******'); if (!$result) throw new Exception('Could not connect to database server'); else return $result;}?>[/code]user_auth_fns.php[code]<?phpfunction register($fname, $lname, $cname, $email, $username, $passwd, $no_tokens){ $conn = db_connect(); $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.'); $result = $conn->query("insert into user values('$fname, $lname, $cname, $email, $username, sha1($passwd), $no_tokens')"); if (!$result) throw new Exception('Could not register you in the database. Please try again later.'); return true; }?>[/code]Anyone have any ideas? Thanks so much in advance. Link to comment https://forums.phpfreaks.com/topic/32216-cannot-execute-query/ Share on other sites More sharing options...
wikedawsum Posted December 29, 2006 Author Share Posted December 29, 2006 Quick update.. I am no longer receiving "could not execute query". I forgot to include my database name in the db_fns.php file. I am, however, getting the "Could not register you in the database. Please try again later." error.Help, please! Link to comment https://forums.phpfreaks.com/topic/32216-cannot-execute-query/#findComment-149553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.