Jump to content

Archived

This topic is now archived and is closed to further replies.

simcoweb

confusing error in mail() function

Recommended Posts

I get this error:

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

from this code:

[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";
}[/code]

with line 24 being the one in red.

[color=red]mail($email, $subject, $row, $header);[/color]

Share this post


Link to post
Share on other sites
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, [color=red]$content[/color], $header);

Orio.

Share this post


Link to post
Share on other sites
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
[code]<?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>";
}
?>[/code]


Ray

Share this post


Link to post
Share on other sites

×

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.