Possible Duplicate:
PHP: mysql_fetch_array() expects parameter 1 to be resource, boolean given
I'm trying to send emails to addresses in a database. the addresses are in two parts: a username (aka 'number') and @something.com (aka 'carrier'). so the email address should be 'number' . 'carrier'
my code is below. the mail function works on its own (not in the loop). the error message i am getting is "mysql_fetch_array() expects parameter 1 to be resource, boolean given in home/username/public_html/script.php on line 15)
#!/usr/bin/php
<?
require_once("PHPMailer/class.phpmailer.php");
// connect to database
mysql_connect("localhost", "username", "password");
mysql_select_db("username_finalproject_Alerts");
// prepare query
$sql = "SELECT number, carrier FROM Alerts";
// execute query
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
//generate email address
$email = $row['number'] . $row['carrier'];
// send mail
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "private stmp address";
$mail->ContentType = 'text/plain';
$mail->IsHTML(false);
$mail->SetFrom("private email address");
$mail->AddAddress($email);
$mail->Subject = "TRY 1";
$mail->Body = "testing 1 2 3";
if ($mail->Send() === false)
die($mail->ErrorInfo . "\n");
}
?>