Forum Moderators: coopster

Message Too Old, No Replies

mail warning message

         

paul161

8:30 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



I created this script as part of my login system. In case someone forgets their password.
I keep on getting the message below any ideas why?

Warning: mail() expects parameter 3 to be string, resource given in /home/paul161/public_html/forgot.php on line 36
An email containing the password has been sent to you

<?PHP

//Database Information

$dbhost = "localhost";
$dbname = "dbname";
$dbuser = "username";
$dbpass = "password";

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$sql="SELECT username,password FROM login1 WHERE email='".$email."'";
$r = mysql_query($sql);
if(!$r) {
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0){
print "no such login in the system. please try again.";
exit();
}
else {
$row=mysql_fetch_array($r);
$username=$row["username"];
$password=$row["password"];

$subject="your password";
$header="from:you@yourdomain.com";
$content="your password is ".$password;
mail($email, $subject, $r, $header);

print "An email containing the password has been sent to you";
}

[edited by: jatar_k at 8:34 pm (utc) on June 20, 2005]
[edit reason] removed specifics [/edit]

jatar_k

8:36 pm on Jun 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



mail($email, $subject, $r, $header);

did you mean to pass $r as your message? Since $r is here

$r = mysql_query($sql);

lobo235

9:20 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



Yeah, i noticed that too. Try:

mail($email, $subject, $content, $header);

instead of

mail($email, $subject, $r, $header);

That should make it work.