Greywacke Posted February 11, 2010 Share Posted February 11, 2010 hi,i am currently struggling to see the worms in the apple. could i perhaps please ask outside assistance, i've tried googling on this error but have found only unrelated examples of this error. i don't see any divisions in these few lines of code.here is the error i receive: Warning: Division by zero in /home/dwtphovu/public_html/ferrety/fab/public/request_canopyxchange.php on line 144Warning: Division by zero in /home/dwtphovu/public_html/ferrety/fab/public/request_canopyxchange.php on line 144and here is the function that contains line 144, the line is made bold:function duplicatedays($mail,$serviceid,$supplierid) { // check supplierid too? $sql = "SELECT smallint_DuplicateDays FROM 2_servicescatalogue WHERE bigint_ServiceID = ".$serviceid.";"; $GLOBALS["sql"] .= $sql; $result = mysql_query($sql); $err = mysql_error(); $GLOBALS["sql"] .= strtoupper($err)."\n"; if ($row = mysql_fetch_array($result)) { $dd = $row["smallint_DuplicateDays"]; } [i]$ddate = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s"),"-".$dd." days"));[/i] [b]$sql = "SELECT bigint_LeadID FROM 6_serviceleads WHERE bigint_ServiceID = ".$serviceid." AND text_Consumer LIKE "%".$mail."%" AND bigint_SupplierID = ".$supplierid." AND timestamp_LeadCreated > ".$ddate." ORDER BY timestamp_LeadCreated DESC;";[/b] $GLOBALS["sql"] .= $sql; $result = mysql_query($sql); $err = mysql_error(); $GLOBALS["sql"] .= strtoupper($err)."\n"; if ($result) { $leadids = array(); while ($row = mysql_fetch_array($result)) { array_push($leadids,"#".($row["bigint_LeadID"]+11001000)); } return " (".join(", ",$leadids).")"; } else { return ""; }} this function is to get a string to append to the subject of the mailed leads IF it is a duplicate lead within the amount of days specified in the database.smallint_DuplicateDays is equal to 30 for bigint_ServiceID 1.i suspect the problem might be elsewhere, possibly in the line that i made italic, which would mean this is quite possibly a displaced error. Link to comment Share on other sites More sharing options...
jeffman Posted February 11, 2010 Share Posted February 11, 2010 It looks like your % operators are outside your quotation marks. That would turn them into PHP modulus operators, so they are trying to perform division. Link to comment Share on other sites More sharing options...
Greywacke Posted February 11, 2010 Author Share Posted February 11, 2010 yeah, just fixed it, read through the sql string to notice that the wildcards where being read as mod's. :/just had to escape the quotes :)so it was not a displaced error ^^ function duplicatedays($mail,$serviceid,$supplierid) { // check supplierid too? $sql = "SELECT smallint_DuplicateDays FROM 2_servicescatalogue WHERE bigint_ServiceID = ".$serviceid.";"; $GLOBALS["sql"] .= $sql; $result = mysql_query($sql); $err = mysql_error(); $GLOBALS["sql"] .= strtoupper($err)."\n"; if ($row = mysql_fetch_array($result)) { $dd = $row["smallint_DuplicateDays"]; } $ddate = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s"),$dd." days ago")); $sql = "SELECT bigint_LeadID FROM 6_serviceleads WHERE bigint_ServiceID = ".$serviceid." AND text_Consumer LIKE \"%".$mail."%\" AND bigint_SupplierID = ".$supplierid." AND timestamp_LeadCreated > ".$ddate." ORDER BY timestamp_LeadCreated DESC;"; $GLOBALS["sql"] .= $sql; $result = mysql_query($sql); $err = mysql_error(); $GLOBALS["sql"] .= strtoupper($err)."\n"; if ($result) { $leadids = array(); while ($row = mysql_fetch_array($result)) { array_push($leadids,"#".($row["bigint_LeadID"]+11001000)); } return " (".join(", ",$leadids).")"; } else { return ""; }} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.