
I'm facing a problem that i cant seem to solve...please so bare in mind that I'm a beginner and my codes might be a lil messy...
problem:
CODE
$count=mysql_num_rows($result);
error: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
this is my full codes...if there any more errors please do tell me...in if possible could i have the solution...thank you...
CODE
<?
include('db.php'); // database connection details stored here
// value sent from form
$email_to=$_REQUEST['email_to'];
//if($_REQUEST['email_to']) $email_to=$_REQUEST['email_to'];
//else die('Email does not have a value');
//// retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
$result= mysql_query ("SELECT USERNAME, EMAIL, PASSWORD FROM Membership WHERE EMAIL= '$email_to' ");
// if found this e-mail address, row must be 1 row
// keep value in variable name "$count"
//$count=mysql_num_rows($result);
//echo $count;
if (isset($result)){
$count=mysql_num_rows($result);
echo 'count = '.$count;
} else
{echo 'No result was returned';}
// compare if $count =1 row
if($count==1){
//$rows=mysql_fetch_array($result);
// keep password in $your_password
$your_password=$rows['PASSWORD'];
$your_username = $rows['USER_NAME'];
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$email_to;
// Your subject
$subject="Your password here";
// From
$header="from: PayPerConest <paypercontest.com>";
// Your message
$messages= "Hello $your_username\r\n";
$messages.= "Your password for login to our website \r\n";
$messages.="Your password is $your_password \r\n";
//$messages.="more message... \r\n";
// send email
$sentmail = mail($to,$subject,$messages,$header);
}
// else if $count not equal 1
else {
echo "Not found your email in our database";
}
// if your email succesfully sent
if($sentmail){
echo "Your Password Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send password to your e-mail address";
}
?>