LiamProductions Posted August 15, 2007 Share Posted August 15, 2007 Hey, I've got an error in my login script i don't quite understand it: <?php if(!isset($_POST['Login'])) { if(!isset($_POST['user'])) { if(!isset($_POST['pass'])) { $user = $_POST['user']; $pass = $_POST['pass']; $user = strip_tags($user); $pass = strip_tags($pass); mysql_connect('localhost', 'liam_liam', 'code090'); mysql_select_db('liam_database'); $checkUser = mysql_query('SELECT * FROM user WHERE username ="'.$user.'" AND password ="'.md5.$pass.'"'); $checkUserRows = mysql_num_rows($checkUser); if($checkUserRows > 0) { $_SESSION['user'] = $user; echo 'Session is set'; } else { echo "Your cannot login because your data is not on my database"; } } else { echo "Please enter a password to login"; } } else { echo "Please enter a username to login"; } } else { echo "You did not fill in all login form"; } ?> Theres a error saying something about a error on mysql_num_rows and its saying You cannot login because your data is not in my database... but the data is... help please. Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/ Share on other sites More sharing options...
The Little Guy Posted August 15, 2007 Share Posted August 15, 2007 $checkUser = mysql_query('SELECT * FROM user WHERE username ="'.$user.'" AND password ="'.md5($pass).'"'); Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324751 Share on other sites More sharing options...
amylou Posted August 15, 2007 Share Posted August 15, 2007 i ran into a problem on my login page also that gave me the same error that user was not in database. i had to change the length of my password to atleast 32 due to the scrambling of it in the database. once i did that the user after entering or registering them again was found. hope that helps Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324756 Share on other sites More sharing options...
ToonMariner Posted August 15, 2007 Share Posted August 15, 2007 hmmm - check your connection details and try echoing out the query to screen copy and paste it into your phpmyadmin (or similar) to see if the query actually returns any records. Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324757 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 $checkUser = mysql_query('SELECT * FROM user WHERE username ="'.$user.'" AND password ="'.md5($pass).'"'); Thanks, I did'nt realise you had to () a md5 Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324758 Share on other sites More sharing options...
The Little Guy Posted August 15, 2007 Share Posted August 15, 2007 did that fix the problem? Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324760 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 I'm still getting the error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/liam/public_html/loginsuccess.php on line 15 Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324764 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 bump Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324771 Share on other sites More sharing options...
The Little Guy Posted August 15, 2007 Share Posted August 15, 2007 Try this: $checkUser = mysql_query('SELECT * FROM user WHERE username ="'.$user.'" AND password ="'.md5($pass).'"')or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324773 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 Try this: $checkUser = mysql_query('SELECT * FROM user WHERE username ="'.$user.'" AND password ="'.md5($pass).'"')or die(mysql_error()); Thank you very much, It would of been lots easier if i spotted it my self... The table was User not user lol but thanks i found the error thanks to that mysql_error Link to comment https://forums.phpfreaks.com/topic/65068-solved-dont-understand-this-error/#findComment-324775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.