2012-01-09 3 views
0

아래 스크립트에서 몇 가지 문제점이 있습니다. 다음 경고가 표시됩니다. 이는 쿼리 결과가 null이라는 것을 의미합니다. 문제는, MySQL 콘솔에서 코드 쿼리 자체를 실행하면 결과가 다시 나타 납니까?mysql 쿼리에서 결과가 수신되지 않습니다.

$gasoil_daily_users = "SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivegasoilmailinglist = 'everyday'"; 
$result = mysql_query($gasoil_daily_users) or die(mysql_error()); 

귀하의 코드가 잘 작동합니다 : 당신이 당신의 쿼리 문자열에 $gasoil_daily_users을 두 번째 줄을 제거하거나 변경하면 mysql_query

$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); 

을 보내고

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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $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("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; 
     } else { 
     echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $row["email"]) . ')<br>'; 
     } 
     // Clear all addresses and attachments for next loop 
     $mail->ClearAddresses(); 
     $mail->ClearAttachments(); 
    } 
    }; 
    //END OF KERO MONTHLY EMAILER 
    ?>  
+0

어떤 쿼리를? 게시 한 코드에는 여러 가지가 있습니다. 또한 거기에 뛰어 들어 귀하의 질문과 관련이없는 것을 제거 할 수 있습니까? 아무도 코드 벽을 헤치고 다니는 것을 좋아하지 않습니다. – jprofitt

+0

mysql_query() 호출 전에 오류 억제 연산자 (@)를 제거하여 오류가 발생했는지 확인하십시오. – jeanreis

+0

그냥 $ result = mysql_query (...) 줄을 찾았을 때, 기대했던대로 작동하지 않고 이전 결과를 덮어 씁니다. – jeanreis

답변

1

당신은 mysql_query.

+0

ahhh 예!, 어리석은 실수 아아, 그 첫 번째 쿼리는 원래 다른 파일에 있었기 때문에 나는 그것을 가로 질러 복사했을 때 쿼리 부분을 제거하지 못했습니다. –

0

당신은 길을 잘못하고있는 - 대신 :

$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)) 
... 

읽어야

$result = mysql_query("SELECT leadname , email FROM hqfjt_chronoforms_data_addupdatelead WHERE receivegasoilmailinglist = 'everyday'") or die(mysql_error()); 
while ($row = mysql_fetch_array ($result)) { 
... 

쿼리를 다시 쿼리 할 필요)

+0

테이블 이름도 확인하십시오. 사용중인 테이블은 테이블 이름이 아닌 전체 외부 이름 (계정 + 테이블 이름)처럼 의심스러워 보입니다. 그리고 나는 당신이 어딘가에서 적절한 데이터베이스 연결과 선택을했다고 가정합니까? 마지막으로, 일단이 작업을하면 MySQLi 또는 PDO로 업데이트하는 것에 대해 생각해보십시오. –

관련 문제