Undefined Variables in PHP4.3.2
Posted: Fri Apr 16, 2004 9:18 am
I am new to using PHP and am receiving the following errors:
1)Notice: Undefined variable: subject in c:\program files\apache group\apache\htdocs\sendnewslettercode.php on line 16
2)Notice: Undefined variable: body in c:\program files\apache group\apache\htdocs\sendnewslettercode.php on line 16
3)Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\apache group\apache\htdocs\sendnewslettercode.php on line 16
the following is the code
Any help with this problem would be greatly appreciated
Thanks
Catherine
[Edit: Added PHP tags around code for eyecandy. --JAM]
1)Notice: Undefined variable: subject in c:\program files\apache group\apache\htdocs\sendnewslettercode.php on line 16
2)Notice: Undefined variable: body in c:\program files\apache group\apache\htdocs\sendnewslettercode.php on line 16
3)Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\apache group\apache\htdocs\sendnewslettercode.php on line 16
the following is the code
Code: Select all
<?php
//make a connection
$connection = mysql_connect("localhost") or die("cannot make connection");
//select the database
$db = mysql_select_db("email" , $connection) or die("cannot find database");
$sql_query = "SELECT email FROM email";
$result = mysql_query($sql_query) or die("cannot execute query");
$header = "From : me@localhost.com";
//loop through rows
while ($row = mysql_fetch_array($result))
{
$address = $row[0];
//mail function requires email address($address)
//The subject($subject) , the message ($body) and
//the $header info
mail($address ,$subject , $body , $header);
//display a message confirming email has been sent
echo ("newsletter sent to : $address<br>");
}
echo ("Completed sending emails");
?>Any help with this problem would be greatly appreciated
Thanks
Catherine
[Edit: Added PHP tags around code for eyecandy. --JAM]