Jump to content

[SOLVED] mysql_num_rows help


methulah

Recommended Posts

$username=$_POST['username'];
$unpassword=$_POST['password'];
$password=md5($unpassword);
dbConnect('delibera_BST');
$sql="SELECT * FROM `users` WHERE username = '$username' AND PASSWORD = '$password'";
$result=mysql_query($sql) or die("NO CAN DO!");
$num = mysql_num_rows($result) or die("NO COUNT!");
if ($num == 1){

 

This brings up the die("NO COUNT!"); message. Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/37719-solved-mysql_num_rows-help/
Share on other sites

I've now changed it to:

AND `password` = '$password'

and changed the die($message) to die(mysql_error()); and now it just brings up a blank screen, whereas it ought to redirect me if one row is returned, or bring up an error message if none.

 

Cheers for your help.

In my opinion, your password is not stored in md5 format, if you are using phpmyadmin than edit the record and select the function column to md5, this way it will convert your stored password value to md5 format.

 

Any also try adding this into your code and see what it does.

 

if ($num == 1)

 

{ echo "No records found";}

 

goodluck

 

 

you may want to enclose the username field as well:

$sql="SELECT * FROM `users` WHERE `username`= '$username' AND `password`= '$password' LIMIT 1";

 

then check :

$error = mysql_error();
if ($error) { return $error; }
else { 
$rows = mysql_num_rows($result); 
if ($rows > 0) { //your command }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.