pranshu82202 Posted December 6, 2011 Share Posted December 6, 2011 Here is my CODE which is showing some error: <?php include('dbcon.php'); session_start(); $usname=$_POST['usname']; $password=$_POST['password']; $usname = stripslashes($usname); $password = stripslashes($password); $usname = mysql_real_escape_string($usname); $password = mysql_real_escape_string($password); $check="y"; $sql = "select * from usname where usname='$usname' and password='$password'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1) { $sqlq = "select * from usname where usname='$usname' and password='$password' and check='$check'"; $resultq=mysql_query($sqlq); $countq=mysql_num_rows($resultq); if($countq==1) {$_SESSION['usname']=$usname; header('location:fire.php');} else {$_SESSION['status']="Admin Didnt grant you the permission to access the things"; header('location:index.php');} } else {$_SESSION['status']="Wrong username and password"; header('location:index.php');} die(" "); ?> And here are the ERRORS when the username and passwords are correct but the check is not equal to 'y'.... Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\money\verify.php on line 18 Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\money\verify.php:18) in C:\xampp\htdocs\money\verify.php on line 24 Please tell me where is the mistake........... Quote Link to comment https://forums.phpfreaks.com/topic/252570-mysql_num_rows-error/ Share on other sites More sharing options...
SergeiSS Posted December 6, 2011 Share Posted December 6, 2011 'password' is reserved word for MySQL, that's why use special letters/quotes (sorry, I don't know exact name for it ) $sql = "select * from `usname` where `usname`='$usname' and `password`='$password'"; Also you would better use it for all: table names and column names. I'd recommend to don't use reserved words for column names at all. PS. "Cannot modify header location..." - you get it because your script print some letters (error message about SQL error) before you try to use function header(...). Solve your SQL problem and then the second problem would be solved automatically. Quote Link to comment https://forums.phpfreaks.com/topic/252570-mysql_num_rows-error/#findComment-1294872 Share on other sites More sharing options...
Adam Posted December 6, 2011 Share Posted December 6, 2011 'password' is not a reserved word in MySQL (see here for full list). You need to handle errors that could be returned from the query. Change any calls to: mysql_query(...) or trigger_error(mysql_error(), E_USER_ERROR); That will trigger a fatal error explaining the problem. Quote Link to comment https://forums.phpfreaks.com/topic/252570-mysql_num_rows-error/#findComment-1294878 Share on other sites More sharing options...
SergeiSS Posted December 6, 2011 Share Posted December 6, 2011 'password' is not a reserved word in MySQL (see here for full Sorry for misinforming... I use MySQL not too often. My "main" DB is Postgre, I like it. That's why I can sometimes say something wrong about MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/252570-mysql_num_rows-error/#findComment-1294884 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.