dongsu1539 2013-09-25 16:15
浏览 15
已采纳

php发送邮件总是错误[重复]

i have an error like this

Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in /home/sibisier/public_html/customer/input_customer_issue.php on line 543

and this is the code in line 543

$query_email = "SELECT employee.nip, employee.nama, employee.job_title,
                                    employee.unit_id, employee.business_email, unit.nama_unit
                                    FROM employee
                                    INNER JOIN unit ON employee.unit_id = unit.unit_id
                                    where employee.job_title IN('Team Leader','Assistant Relationship Manager','PROFESSIONAL STAFF')
                                    AND employee.unit_id IN(12)";

                    $resul1 = mysql_query($query_email) or die(mysql_error());{
                        $to = $resul1['business_email'];
                        $subject = 'Notifikasi';

                        $message = "<table>";
                        $message .= "<tr><td>Date</td><td>:</td><td>" . $tanggal_sekarang . "</td></tr>";
                        $message .= "<tr><td>NIP</td><td>:</td><td>" . $nip . "</td></tr>";
                        $message .= "<tr><td>Unit</td><td>:</td><td>" . $resul1['nama_unit'] . "</td></tr>";
                        $message .= "<tr><td>CIF</td><td>:</td><td>" . $cif . "</td></tr>";
                        $message .= "<tr><td>Comment</td><td>:</td><td>" . $comment . "</td></tr>";
                        $message .= "</table>";
                        $headers = "From: admin@sibisiser.com 
";
                        $from .= "Reply-To: zack.zacky14@gmail.com 
";
                        $from .= "Content-type: text/html 
";
                        mail($to, $subject, $message,$headers, $from);
                        echo "Mail Sent.";

i have no idea, i've been search and always get this error.

please i need help. thanks

</div>
  • 写回答

1条回答 默认 最新

  • dps43378 2013-09-25 16:37
    关注

    Download PHPMailer package from: http://phpmailer.worxware.com/

    and try this code->

    <?php
    require_once('PHPMailer/class.phpmailer.php');
    
    $query_email = "SELECT employee.nip, employee.nama, employee.job_title,
                                        employee.unit_id, employee.business_email, unit.nama_unit
                                        FROM employee
                                        INNER JOIN unit ON employee.unit_id = unit.unit_id
                                        where employee.job_title IN('Team Leader','Assistant Relationship Manager','PROFESSIONAL STAFF')
                                        AND employee.unit_id IN(12)";
    
                            $resul1 = mysql_query($query_email) or die(mysql_error());
    
                            $row=mysql_fetch_array($resul1, MYSQL_ASSOC);
                            if($row)   {
                            $to = $row['business_email'];
                            $htmlbody =  '<table>
                            <tr><td>Date</td><td>:</td><td> '. $tanggal_sekarang .' </td></tr>
                            <tr><td>NIP</td><td>:</td><td> '. $nip .' </td></tr>;
                            <tr><td>Unit</td><td>:</td><td> '. $resul1['nama_unit'] .' </td></tr>;
                            <tr><td>CIF</td><td>:</td><td> '. $cif .' </td></tr>;
                            <tr><td>Comment</td><td>:</td><td> '. $comment .' </td></tr>;
                            </table>';
    
                            $mail = new PHPMailer();
                            $mail->From      = 'admin@sibisiser.com';
                            $mail->FromName  = 'yourName';
                            $mail->Subject   = 'Notifikasi';
                            $mail->Body      = $htmlbody;
                            $mail->AddAddress($to);
                            $mail->Send();
    
    
    
        }
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?