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
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.

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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 }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.