ram4nd Posted September 30, 2009 Share Posted September 30, 2009 Can anybody tel me that why am i getting these errors: Errors: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/PTC/login.php on line 9 Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /opt/lampp/htdocs/PTC/login.php on line 10 Code: mysql_connect('localhost','something','else'); mysql_select_db('PTC'); $a = 'SELECT id FROM members WHERE user = '.clean($_POST['user']).' AND pass = '.md5($_POST['pass']); $b = mysql_query($a); $query = mysql_fetch_array($b); if(mysql_num_rows($query) == 1) { $_SESSION['user'] = $query['id']; setcookie('user', $query['id'], (60 * 60 * 24 * 30 + $_SERVER['REQUEST_TIME'])); header('Location: members.php'); } else $x = 'Incorrect username or password.'; Quote Link to comment https://forums.phpfreaks.com/topic/176020-solved-2-simple-sql-errors/ Share on other sites More sharing options...
Zane Posted September 30, 2009 Share Posted September 30, 2009 $b = mysql_query($a) or die("Query: $a " . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/176020-solved-2-simple-sql-errors/#findComment-927489 Share on other sites More sharing options...
ram4nd Posted September 30, 2009 Author Share Posted September 30, 2009 Query: SELECT id FROM members WHERE user=ram4nd AND pass=2f951cd95999b19a22fbc1037e552336 Unknown column 'ram4nd' in 'where clause' Quote Link to comment https://forums.phpfreaks.com/topic/176020-solved-2-simple-sql-errors/#findComment-927493 Share on other sites More sharing options...
corbin Posted September 30, 2009 Share Posted September 30, 2009 It's assuming it's a column name since it's not in quotes. (I suggest using single quotes around it.) Quote Link to comment https://forums.phpfreaks.com/topic/176020-solved-2-simple-sql-errors/#findComment-927495 Share on other sites More sharing options...
ram4nd Posted September 30, 2009 Author Share Posted September 30, 2009 Warning: mysql_num_rows() expects parameter 1 to be resource, array given in /opt/lampp/htdocs/PTC/login.php on line 10 $a = 'SELECT id FROM members WHERE user=\''.clean($_POST['user']).'\' AND pass=md5('.$_POST['pass'].')'; Quote Link to comment https://forums.phpfreaks.com/topic/176020-solved-2-simple-sql-errors/#findComment-927523 Share on other sites More sharing options...
ram4nd Posted September 30, 2009 Author Share Posted September 30, 2009 I had mysql_fetch_array in mysql_num_rows. Quote Link to comment https://forums.phpfreaks.com/topic/176020-solved-2-simple-sql-errors/#findComment-927543 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.