The script I'm trying to create involves sending an email to a person's email address which is stored within a database.
I have unit-tested the modules establishing the SQL connection, getting a result set in an array, sending an echo to the web page with the result set and of course sending mail using the Mail function.
All three work like a charm when separated, when put together and with the variables used in the mail function it doesn't sent an email whatsoever.
To make the coding more easier, it doesn't need any user-input. A cron-job will do the job starting up the php page via lynx.
Thanks in advance,
Greets, Novunimic
- Code: Select all
<?php
$con = mysql_connect("localhost","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$result = mysql_query("SELECT Emailaddress FROM table where Firstname = Name");
while($row = mysql_fetch_array($result))
{
mail($result['Emailaddress'],'subject','text');
}
mysql_close($con);
?>

