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. Quote Link to comment 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).'"'); Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted August 15, 2007 Share Posted August 15, 2007 did that fix the problem? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 bump Quote Link to comment 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()); Quote Link to comment 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 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.