Jump to content


Photo

confusing error in mail() function


  • Please log in to reply
3 replies to this topic

#1 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 13 October 2006 - 06:53 PM

I get this error:

Warning: mail() expects parameter 3 to be string, array given in /home2/wwwxxxx/public_html/forgot.php on line 24


from this code:

else {
$row=mysql_fetch_array($r);
$password=$row["password"];
$email=$row["email"];
$subject="your password";
$header="from:admin@plateauprofessionals.com";
$content="Hello. As per your request your password is ".$password;
mail($email, $subject, $row, $header);
print "<h2>Password Sent</h2><p><font class='bodytext'>An email containing the password has been sent to you.<BR>\n";
}

with line 24 being the one in red.

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

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 13 October 2006 - 07:08 PM

Because the third parameter you gave is an array, $row. I think you meant to write $content instead of $row, so the line would look like this:
mail($email, $subject, $content, $header);

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 13 October 2006 - 07:12 PM

well it says exactly that. You used $row for one of your parameters. $row is an array from the database.

mail function works like so

mail($to, $subject, $message, $headers)

try this out
<?php
$bcc = $email;
$to = "";
$subject = "Your Password";
$headers = "From: admin@plateauprofessionals.com\r\n";
$headers .= "BCC: $bcc\r\n";

//leave the next 2 lines alone
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message="Hello. As per your request your password is ".$password;

if(mail($to,$subject,$message,$headers)){
echo "<p align=center class=returns>Password has been sent<br /></p>";
} else {
echo "<p align=center class=returns>Could not send E-Mail!<br /></p>";
}
?>


Ray


#4 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 13 October 2006 - 08:49 PM

Ok, swapped that out and error went away. Thanks guys!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users