phpperson Posted October 15, 2013 Share Posted October 15, 2013 The code you are about to see is for a register page and i keep getting this error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\register.php on line 22 could someone HELP!!!!!!!!: <?php require 'datebase.inc.php'; require'thecore.inc.php'; if(!loggedin()) { if(isset($_POST['username'])&&isset($_POST['surname'])&&isset($_POST['password'])&&isset($_POST['password_again'])) { $Username = $_POST['username']; $Surname = $_POST['surname']; $Password = $_POST['password']; $password_again = $_POST['password_again']; if (!empty($Username)&&!empty($Surname)&&!empty($Password)&&!empty($password_again)){ if ($Password!==$password_again) { echo 'Password does not match'; }else{ $query = "SELECT `username` FROM `user` WHERE `username` = '$Username'"; $query_run = mysql_query($query); if(mysql_num_rows($query_run)==1) { echo 'The username'.$Username.'already exists.'; }else{ echo 'OK'; } } }else{ echo 'Fill in the fields'; } } } ?> <form action="register.php" method="POST"> <input type="text" name="username" placeholder="Username..." value="<?php echo $Username;?>"> <input type="text" name="surname" placeholder=" Surname... " value="<?php echo $Surname;?>"><br><br> <input type="password" name="password" placeholder=" Password..."><br><br> <input type="password" name="password_again" placeholder=" Password again..."><br><br> <input type="submit" Value="Register"> </form> Quote Link to comment Share on other sites More sharing options...
jcbones Posted October 15, 2013 Share Posted October 15, 2013 Your query is failing, and returning a boolean false, not a resource. Check mysql_error() for the failure, then change everything to mysqli or PDO Quote Link to comment Share on other sites More sharing options...
phpperson Posted October 15, 2013 Author Share Posted October 15, 2013 Your query is failing, and returning a boolean false, not a resource. Check mysql_error() for the failure, then change everything to mysqli or PDO I fixed Quote Link to comment 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.