simcoweb Posted October 13, 2006 Share Posted October 13, 2006 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:[email protected]";$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 https://forums.phpfreaks.com/topic/23885-confusing-error-in-mail-function/ Share on other sites More sharing options...
Orio Posted October 13, 2006 Share Posted October 13, 2006 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. Link to comment https://forums.phpfreaks.com/topic/23885-confusing-error-in-mail-function/#findComment-108546 Share on other sites More sharing options...
craygo Posted October 13, 2006 Share Posted October 13, 2006 well it says exactly that. You used $row for one of your parameters. $row is an array from the database.mail function works like somail($to, $subject, $message, $headers)try this out[code]<?php$bcc = $email;$to = "";$subject = "Your Password";$headers = "From: [email protected]\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 https://forums.phpfreaks.com/topic/23885-confusing-error-in-mail-function/#findComment-108548 Share on other sites More sharing options...
simcoweb Posted October 13, 2006 Author Share Posted October 13, 2006 Ok, swapped that out and error went away. Thanks guys! Link to comment https://forums.phpfreaks.com/topic/23885-confusing-error-in-mail-function/#findComment-108614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.