I have had a usage reporting system in place for sometime to notify users that they are using too much data. Suddenly random lines stopped reporting. I assumed there was just an error in the data going in, but I have thoroughly check it and can find no reason why this would be occurring.
Here is what I have set-up:
Alert system:
#!/usr/bin/php -q
<?php
$db_host = "localhost";
$db_username = "XXX";
$db_pass = "XXX";
$db_name = "XXX";
mysql_connect("$db_host","$db_username","$db_pass") or die(mysql_error());
mysql_select_db("$db_name") or die ("no database");
$sql = "SELECT date,phonenumber,email, dataplan AS currentplan, SUM(datamb) AS value_sum FROM maindata2 GROUP BY phonenumber, dataplan";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
if ($result) {
$row = mysql_fetch_assoc($result);
$plan = $row['currentplan'] ;
$date = $row['date'] ;
$inventory = ROUND ($row["value_sum"],2) ;
$recipient = $row['email'];
$line = $row['phonenumber'];
if ($inventory > (.75 * $plan)) {
$msg = "message";
mail($recipient,, "Alert from ", $msg);
}
}
else {
$msg = "An error occurred: " . mysql_error();
mail($recipient, "Alert from ", $msg, $headers);
}
}
?>
The Data I am using is the following:
"5/28/2014","xxx-xxx-0904","20","email@email.com, email@email.com, email@email.com","461.80","email@email.com"
"5/28/2014","xxx-xxx-0905","20","email@email.com, email@email.com, email@email.com","418.80","email@email.com"
"5/28/2014","xxx-xxx-0906","20","email@email.com, email@email.com, email@email.com","461.80","email@email.com"
The middle line does not report, all others do. Any thoughts would be great, I have tried changing the group by to every possible combination, but I can not get that middle line to report.