Heyya
when you get a error like: Supplied argument is not a valid MySQL result resource that means that there was an error with your SQL query and because of that the result resource it would normaly returned is no longer valid.
This is why you should always check to make sure your result resouce is valid before performing operations on it like mysql_num_rows();
You can check it simply by :
if(!$result){
echo "Email address could not be found!";
return false;
}
//Other wise go on as normal
$count = mysql_num_rows($result);
if ($count==0){
echo "Username / Password Incorrect";
exit;
}
else{
echo "logged in";
$HTTP_SESSION_VARS['emailaddress'] = $emailaddress;
}
now that you're added some basic error checking to your code... it's time to find out why there was no result returned from SQL... either there's a syntax error with your query, or there really was no match in the database, and thus the query returned nothing.
First, you should always put quotes around strings in your SQL querys. That will cause an error if there is any spaces in those fields. Sure email addresses and passwords ususally don't have spaces, but it's still good practice.
$sql = "SELECT emailaddress FROM customers Where emailaddress = '".$emailaddress."' && password = '".$password."'";
echo $sql;
I put an echo in there to print the query out on the screen. Copy and paste what it prints out into your database program. Hopefully you're using something like SQLyog which makes this a very quick and easy process.
Check what SQLyog or similar does with this query. It should show you what's going on. I.e. show you if it's returning any results, or if there are syntax errors in your query.
So hopefully that should help you out.
cya man,
-Adam 🙂