我有一些問題,我下面的腳本,我得到以下警告,我相信是指查詢的結果是空的結果?但事情是,如果我在MySQL控制檯中運行代碼查詢本身,我會返回結果?沒有收到來自MySQL查詢
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\server2go \server2go\htdocs\chandlers\components\com_jumi\views\application\view.html.php(38) : eval()'d code on line 53
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\server2go \server2go\htdocs\chandlers\components\com_jumi\views\application \view.html.php(38) : eval()'d code on line 93
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\server2go \server2go\htdocs\chandlers\components\com_jumi\views\application\view.html.php(38) : eval()'d code on line 134
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\server2go \server2go\htdocs\chandlers\components\com_jumi\views\application\view.html.php(38) : eval()'d code on line 177
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\server2go \server2go\htdocs\chandlers\components\com_jumi\views\application\view.html.php(38) : eval()'d code on line 218
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\server2go \server2go\htdocs\chandlers\components\com_jumi\views\application\view.html.php(38) : eval()'d code on line 259
<?php
// SETS THE TIMEZONE TO UK TIME
date_default_timezone_set('Europe/London');
// DEFINES WEEKDAY AND DAY OF THE MONTH
$weekday = date('D');
$dayOfMonth = date('d');
// RUNS THE EVERY DAY FUNCTIONS TO MAIL USERS IN THAT GROUP EVERY DAY
gasoildailyemailer();
dervdailyemailer();
kerodailyemailer();
if ($weekday == 'Mon')
{
// RUNS THE WEEKLY FUNCTIONS TO MAIL USERS IN THAT GROUP EVERY WEEK
gasoilweeklyemailer();
dervweeklyemailer();
keroweeklyemailer();
if ($dayOfMonth <=6) {
// RUNS THE MONTHLY FUNCTIONS TO MAIL USERS IN THAT GROUP EVERY MONTH
gasoilmonthlyemailer();
dervmonthlyemailer();
keromonthlyemailer(); }
}
?>
<?php
//start of gas oil daily emailer
function gasoildailyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test";
$gasoil_daily_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivegasoilmailinglist = 'everyday'") or die(mysql_error());
$result = @MYSQL_QUERY($gasoil_daily_users);
while ($row = mysql_fetch_array ($result)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
?>
<?php
// START OF DERV DAILY EMAILER
function dervdailyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test";
$derv_daily_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivedervmailinglist = 'everyday'") or die(mysql_error());
$result1 = @MYSQL_QUERY($derv_daily_users);
while ($row = mysql_fetch_array ($result1)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
// end of DERV daily emailer
?>
<?php
//start of KERO daily emailer
function kerodailyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test";
$kero_daily_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivekeromailinglist = 'everyday'") or die(mysql_error());
$result2 = @MYSQL_QUERY($kero_daily_users);
while ($row = mysql_fetch_array ($result2)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
// end of KERO daily emailer
?>
<?php
// start of GAS OIL WEEKLY emailer
function gasoilweeklyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test Weekly";
$gasoil_every_mon_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivegasoilmailinglist = 'everymonday'") or die(mysql_error());
$result3 = @MYSQL_QUERY($gasoil_every_mon_users);
while ($row = mysql_fetch_array ($result3)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
//end of GAS OIL WEEKLY emailer
?>
<?php
// START OF DERV WEEKLY EMAILER
function dervweeklyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test Weekly";
$derv_every_mon_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivedervmailinglist = 'everymonday'") or die(mysql_error());
$result4 = @MYSQL_QUERY($derv_every_mon_users);
while ($row = mysql_fetch_array ($result4)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
// END OF DERV WEEKLY EMAILER
?>
<?php
// START OF KERO WEEKLY EMAILER
function keroweeklyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test Weekly";
$kero_every_mon_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivekeromailinglist = 'everymonday'") or die(mysql_error());
$result5 = @MYSQL_QUERY($kero_every_mon_users);
while ($row = mysql_fetch_array ($result5)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
// END OF KERO WEEKLY EMAILER
?>
<?php
// START OF GAS OIL MONTHLY EMAILER
function gasoilmonthlyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test monthly";
$gasoil_1st_mon_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivegasoilmailinglist = 'firstmondayofthemonth'") or die(mysql_error());
$result6 = @MYSQL_QUERY($gasoil_1st_mon_users);
while ($row = mysql_fetch_array ($result6)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
// END OF GAS OIL MONTHLY EMAILER
?>
<?php
//START OF DERV MONTHLY EMAILER
function dervmonthlyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test monthly";
$derv_1st_mon_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivedervmailinglist = 'firstmondayofthemonth'") or die(mysql_error());
$result7 = @MYSQL_QUERY($derv_1st_mon_users);
while ($row = mysql_fetch_array ($result7)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
//END OF DERV MONTHLY EMAILER
?>
<?php
// START OF KERO MONTHLY EMAILER
function keromonthlyemailer(){
require_once('./send/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
// $body = file_get_contents('contents.html');
$body = 'Dear Test this is a test.';
// $body = preg_replace('/\\\\/i', $body);
$mail->SetFrom('[email protected]', 'List manager');
$mail->AddReplyTo('[email protected]', 'List manager');
$mail->Subject = "Mailing List Test monthly";
$kero_1st_mon_users = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivekeromailinglist = 'firstmondayofthemonth'") or die(mysql_error());
$result8 = @MYSQL_QUERY($kero_1st_mon_users);
while ($row = mysql_fetch_array ($result8)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($row["email"], $row["leadname"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send()) {
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>';
} else {
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
};
//END OF KERO MONTHLY EMAILER
?>
哪個查詢?您發佈的代碼中有多個。你還可以跳進去,去掉任何與你的問題無關的東西 - 沒有人喜歡穿過一層代碼。 – jprofitt 2012-01-09 14:27:49
嘗試在調用mysql_query()之前刪除錯誤抑制操作符(@),以查看是否觸發了任何錯誤。 – jeanreis 2012-01-09 14:28:13
只要注意,溝美元結果= mysql_query(...)線,它沒有做你期望的(它覆蓋你以前的結果)。 – jeanreis 2012-01-09 14:29:50