9three Posted January 10, 2009 Share Posted January 10, 2009 Every time I hit register, i get 2 errors and one thrown exception. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Users\9three\Desktop\Server\htdocs\CMS\admin\add.php on line 27 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Users\9three\Desktop\Server\htdocs\CMS\admin\add.php on line 33 Fatal error: Uncaught exception 'Exception' with message 'Unable to query' in C:\Users\9three\Desktop\Server\htdocs\CMS\admin\includes\library\mysql.class.php:40 Stack trace: #0 C:\Users\9three\Desktop\Server\htdocs\CMS\admin\add.php(43): mysql->query('INSERT INTO adm...') #1 {main} thrown in C:\Users\9three\Desktop\Server\htdocs\CMS\admin\includes\library\mysql.class.php on line 40 <?php require('includes/includes.php'); if(isset($_POST['register'])) { $connection = new mysql('localhost', 'root', ''); $connection->select('cms'); /** * Sanitize all possible input values * Force first charater in username to be capitilized * Force email to be all lowercase */ $username = escape(ucfirst($_POST['username'])); $password = escape(secure($_POST['password'])); $email = escape(strtolower($_POST['email'])); $qusername = "SELECT Username FROM admins WHERE Username = '$username'"; $qemail = "SELECT Email FROM admins WHERE Email = '$email'"; //Check if Username is taken if (mysql_num_rows($qusername) > 0) { echo 'Username is taken, please select another'; exit; } //Check if Email is taken elseif (mysql_num_rows($qemail) > 0) { echo 'Email is taken, please use another'; exit; } else { $query = "INSERT INTO admins (Username, Password, Email) VALUES ('$username', '$password', '$email')"; $register = $connection->query($query); if ($register) { echo 'Registration complete. You may now login.'; } else { echo 'There was a problem during registration, please try again.'; } } } ?> I have tried echo mysql_error but the only thing that shows up is mysql_num_rows error. I also tried to echo the query and manually put it into my database and it works fine. Link to comment https://forums.phpfreaks.com/topic/140329-solved-trying-to-register-problems/ Share on other sites More sharing options...
xtopolis Posted January 10, 2009 Share Posted January 10, 2009 You never query $qusername or $qemail Link to comment https://forums.phpfreaks.com/topic/140329-solved-trying-to-register-problems/#findComment-734347 Share on other sites More sharing options...
ILMV Posted January 10, 2009 Share Posted January 10, 2009 $username= mysql_query($qusername); $email= mysql_query($q email); Link to comment https://forums.phpfreaks.com/topic/140329-solved-trying-to-register-problems/#findComment-734349 Share on other sites More sharing options...
9three Posted January 11, 2009 Author Share Posted January 11, 2009 oops lol my bad Link to comment https://forums.phpfreaks.com/topic/140329-solved-trying-to-register-problems/#findComment-734833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.