I am trying to get the content's of a database and have it emailed to me, upon my filling out a form that will be behind a authenticated directory.
I am getting this result:
Array
Warning: mail() expects parameter 3 to be string, resource given in send.php on line 26
Here is the code:
$result = mysql_query('SELECT * FROM db1');
if (!$result) {
die('Could not query:' . mysql_error());
}
echo mysql_fetch_array ($result);
if (!$email) {
$email = "My Name<MyEmail@MyDomain.com>";
}
$nrecipient = "My_Email@MyDomain.com";
$nsubject = 'Email Database';
$nheaders = "From: $email\r\n";
$nheaders .= "CC: [email]MyBackupemail@mydomain.com[/email]\r\n";
$nheaders .= "Importance: high\r\n";
$nheaders .= "X-Priority: 1\r\n";
$nheaders .= "X-MSMail-Priority: High\r\n";
$nheaders .= "Organization: MyDomain.com\r\n";
$chk_sent = mail($nrecipient,$nsubject,$result,$nheaders);
if ($chk_sent) {
print "<font color=\"black\">sent!\n";
} else {
print "<font color=\"black\">not sent!\n";
}
The problem appears to be $result which it is saying that it needs to be a "STRING".
How can I do this, where it will send everything in the database in the email, in CSV format?
Thank you!
Rich