Blekk Posted December 3, 2006 Share Posted December 3, 2006 Hi, I used to do a bit of php, but stopped for ages, now I was trying to refresh my memory by creating a simple login. Here it is:[code]$query = "SELECT * FROM te_users WHERE username='".mysql_real_escape_string($username)."','".md5($password)."'";$result = mysql_query($query);$rows = mysql_num_rows($result);if($rows == 1){print"$username has logged in.";}else{print "Incorrect username or password";}[/code]I get the exception:[quote]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result...[/quote]I remember using mysql_num_rows() last time I did this(a very long time ago lol), why will it not work now?Thanks,Any reply is appreciated. Link to comment https://forums.phpfreaks.com/topic/29328-very-simple-login-code-not-working/ Share on other sites More sharing options...
trq Posted December 3, 2006 Share Posted December 3, 2006 This means your query is failing, use a die() statement along with mysql_error() to handle some debugging, but I can tell you now, you dont specify a passwrd field.Try something like...[code=php:0]$query = "SELECT * FROM te_users WHERE username='".mysql_real_escape_string($username)."' AND pass='".md5($password)."'";$result = mysql_query($query) or die(mysql_error());[/code] Link to comment https://forums.phpfreaks.com/topic/29328-very-simple-login-code-not-working/#findComment-134443 Share on other sites More sharing options...
Blekk Posted December 3, 2006 Author Share Posted December 3, 2006 Wow, I cannot believe I didn't see that I hadn't specified a password field, My...God...I am stupid.Thanks thorpe Link to comment https://forums.phpfreaks.com/topic/29328-very-simple-login-code-not-working/#findComment-134446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.