Jump to content

confusing error in mail() function


simcoweb

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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.