0

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 \n";
                        $from .= "Reply-To: zack.zacky14@gmail.com \n";
                        $from .= "Content-type: text/html \r\n";
                        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

zacky
  • 61
  • 1
  • 1
  • 8
  • 1
    The code you've included doesn't include `mysql_fetch_array()` – andrewsi Sep 25 '13 at 16:17
  • i use to try much but it still not working, can you define step by step? – zacky Sep 25 '13 at 16:28
  • sorry im newbie in here but thanks – zacky Sep 25 '13 at 16:28
  • You're missing a few lines between your mysql_query and your $to line. Can you add more code? – aynber Sep 25 '13 at 16:29
  • what kind of code? really dont have idea with this case – zacky Sep 25 '13 at 16:31
  • What you actually have in the file input_customer_issue.php – aynber Sep 25 '13 at 16:32
  • field input that i want to send to business email in that query and also save it to database.. – zacky Sep 25 '13 at 16:36
  • Nonono. The code you posted above is apparently missing a few lines since it does not show mysql_fetch_array. Edit your post and show us the full code block from lines 535-560. (Guessing on the numbers, but it should be enough around 543 to show us your full code) – aynber Sep 25 '13 at 16:39

1 Answers1

1

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



    }

?>
jGupta
  • 2,243
  • 4
  • 22
  • 49
  • thanks sanki, its works to my error. but the email was not send. you know why maybe? – zacky Sep 25 '13 at 16:53
  • sometimes it takes around 15 mins for email to be received due to congestion in network.. keep sending mails at least 4-5 times. I know this is really dumbest suggestion you wud have ever heard but i try this whenevr the mail gets delayed and that works for me atleast :) – jGupta Sep 25 '13 at 16:55
  • ok i'll send email again, really thanks in advance sanki :) i'll update when my email is send :D – zacky Sep 25 '13 at 16:58
  • heyy there was some errors in the code.. edited code is well tested and works fine.. try edited code now.. – jGupta Sep 25 '13 at 19:01
  • IT'S WORKKKKKKKKKKK!!!!!!!! really thanks in advance sanki :) you safe my life :) – zacky Sep 26 '13 at 04:27