Thursday, 26 September 2013

Cannot retrieve all row in table php, only half is retrieved

Cannot retrieve all row in table php, only half is retrieved

I have a table named 'laptop' and a column inside the table named
'Lap_War_Expiry'. The code run well as what I have edit in previous
posting, How to retrieve more than one data in email? . However, the code
only run for 45 data only. It supposed to be 100 data and sent the email
to user. (I know it sounds too many of email, but before I try to combine
the data in one email, I need to make sure all the data is retrieved
first)
I try to change the php.ini config below but still cannot retrieve all the
needed email. Is there anywhere that I should change other than this ? Or
is it my configuration is not right ?
max_execution_time = 0 ; Maximum execution time of each script, in
seconds
max_input_time = 0 ; Maximum amount of time each script may spend parsing
request data
;max_input_nesting_level = -1 ; Maximum input variable nesting level
memory_limit = 128M ; Maximum amount of memory a script may consume
(128MB)
This is my coding for sending the email :
<?php
require 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = 'smtp';
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
// ======== get database data ==================
$link = mysql_connect("localhost","root","");
$database="master_inventory";
mysql_select_db ($database,$link) OR die ("Could not open $database" );
$query2 = 'SELECT Lap_PC_Name, Lap_War_Expiry FROM laptop';
name.
$result1 = mysql_query($query2);
//$query2='SELECT GetDate(), Lap_War_Expiry, DATEDIFF(GetDate(),
Lap_War_Expiry) AS
diff FROM laptop where DATEDIFF(GetDate(), Lap_War_Expiry) < 1';
//$result1 = mysql_query($query2);
while($row = mysql_fetch_array($result1)) {
$Lap_PC_Name = $row['Lap_PC_Name'];
$Lap_War_Expiry = $row['Lap_War_Expiry'];
$date=$row['Lap_War_Expiry'];
// $date is get from table
$date = date ('d-m-Y')||('d/m/Y') + (7 * 24 * 60 * 60);
$newdate = strtotime ( '+45 days' , strtotime ( $row['Lap_War_Expiry']) ) ;
$newdate = date ( 'd/m/Y' , $newdate );
if ($newdate <45) {
$mail->Username = "myemail@gmail.com";
$mail->Password = "password";
$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->SingleTo = true;
$mail->From = "assetmanagementsystemauosp@gmail.com";
$mail->FromName = "Asset Management System";
$mail->addAddress("email@gmail.com","Asset Management System");
$mail->Subject = "Notification on warranty expiry";
$mail->Body = "Dear IT Infra,<br/><br />The licensed for the following PC
will expired
in less than one month.<br /><br /> PC Name : ".$Lap_PC_Name. "<br />Date
of expired :"
.$Lap_War_Expiry;
if(!$mail->Send())
echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
else
echo "Message has been sent";
}
else {
echo "No PC expired less than 45 days for today. ";
}
}
?>

No comments:

Post a Comment