Jump to content

Greywacke

Members
  • Posts

    510
  • Joined

  • Last visited

Everything posted by Greywacke

  1. ok i wrote the variable down after getting it, and its all perfect. only problem is the $expected variable is dropped in the 21 lines before its used 0o.
  2. well the problem is somewhere between where the function is called and where the variable is used.i have marked these lines as bold and red. [color="#FF0000"][b]$expected = getexpected($attribsarr["fitment"]);[/b][/color]$tsql = "SELECT * FROM 7_blacklist WHERE `text_E-mailAddress` = \"".$consumeremail."\";";$result = mysql_query_errors($tsql, $conn , __FILE__ , __LINE__ , false);if (mysql_errno()> 0) { $sql .= $tsql; $sql .= strtoupper($err)."\n";}if ($result) { if (mysql_num_rows($result) > 0) { if ($row = mysql_fetch_array($result)) { echo mysql_real_escape_string("Your e-mail address has been "."blacklisted\n"."for ".$row["text_ListedReason"].".\n\nPlease mail info@ferrety.co.za for more ". "information."); } } else { getsuppliers($service,0); dropattribs(0); $x = supplierswanted(0, $service, $region); while (count($mailadds) > $x) { array_pop ($mailadds); } //echo count($mailadds);// loop through available suppliers and their recipients foreach ($mailadds as $recipient) {// calculate service cost for the supplier $servicecost = costbycategory($service,$attribsarr,$recipient[9]);// check duplicate days $append = duplicatedays($consumeremail,$service,$recipient[6]); [color="#FF0000"][b]$sql1 = "INSERT INTO 6_serviceleads ("."text_Consumer, text_LeadSubject, text_LeadAttributes, timestamp_ExpectedBy, "."text_LeadMessage, bigint_ServiceID, bigint_SupplierID, bigint_RegionID) VALUES "."(\"".$consumerfullname.";".$consumeremail.";".$consumercell.";".$city_town."\",\"".$append."\",\"".$attribs."\",\"".[u]$expected[/u]."\",\"".$message."\",".$service.",".$recipient[6].",".$region.");";[/b][/color] the attributes get inserted though, and are available on the page - yet the variable $expected gets dropped for some reason.
  3. it gets it now with the dateadd function, but for some reason if i do $expected = getexpected($attribsarr["fitment"]); then it does not insert it into the database when i call this update, about 15 lines down: $sql1 = "INSERT INTO 6_serviceleads (text_Consumer, text_LeadSubject, text_LeadAttributes, timestamp_ExpectedBy, text_LeadMessage, bigint_ServiceID, bigint_SupplierID, bigint_RegionID) VALUES (\"".$consumerfullname.";".$consumeremail.";".$consumercell.";".$city_town."\",\"".$append."\",\"".$attribs."\",\"".$expected."\",\"".$message."\",".$service.",".$recipient[6].",".$region.");";$result1 = mysql_query_errors($sql1, $conn , __FILE__ , __LINE__ , false); it does not use the variable $expected anywhere else on the page.
  4. ah it should have added days to the current date, and the value i was looking for is not day. it is mday.this function works adding the amount of days passed as parameter to the current date and returning one minute to midnight SAST on that date. function dateadd($interval) { $now = getdate(strtotime(convert_tz(date("Y-m-d H:i:s", time()),"SAST"))); return date("Y-m-d H:i:s",mktime(23,59,59,$now["mon"],$now["mday"] + $interval,$now["year"]));}
  5. hi there,currently i am testing a new function to automatically calculate the date a product can be expected.the code is as follows: <?phpinclude('includes/statistical/timezones/class-timezone-conversion.php'); /** Include timezone conversion class */// test timezone conversion of current date with dateadd.function convert_tz($timestamp, $timezone) { /** convert local datetime to SAST (South African Standard Time) */ $tz = new TimezoneConversion(); /** Create TimezoneConversion Object */ $tz->setProperty('DateTime', $timestamp); /** Set local 'DateTime' to convert */ $tz->setProperty('Timezone', $timezone); /** Set Timezone Convert To */ return $tz->convertDateTime(); /** Get SAST Timestamp */}function dateadd($interval) { $now = getdate(strtotime(convert_tz(date("Y-m-d H:i:s", time()),"SAST"))); return date("Y-m-d H:i:s",mktime(23,59,59,$now["mon"],$now["day"] + $interval,$now["year"]));}function getexpected($fitment) { switch ($fitment) { case "ASAP": return dateadd(7); break; case "within_2_weeks": return dateadd(14); break; case "within_month": return dateadd(30); break; case "within_2_months": return dateadd(60); break; case "within_3_months": return dateadd(90); break; case "not_within_3_months": return dateadd(120); break; default: return "0000-00-00 23:59:59"; }}echo dateadd(7);echo "<br />\n";echo getexpected("within_2_weeks");?> and it returns as follows: 2010-10-07 23:59:592010-10-14 23:59:59 this is almost right, except that it doest add 7 or 14 days to todays date which is the 25th. i have absolutely no idea why this would be. somebody please help!
  6. okay, i've found some records don't have all the attributes. a few are for both QM and have the fitment attribute located as the 3rd attribute, while some have extra attributes. 0o going to work a bit more at that if statement, also realised that my main problem was the if statement checking for larger than -1 - it should have been > 0. mysql INSTR functions calculate positions from 1 and no position from 0. haris s, hehe i know a normal update statement - but this is hardly normal - i post here so others may read and become more familiar with advanced mysql queries. :)with 4817 records, this query runs in 0.107 seconds and returns only 34 records with 0000-00-00 TIME as a timestamp_ExpectedBy value. will discuss with my client wether he wants the records with extra attributes at the end to have those attributes removed or not. i could do this in PHP easily, but getting named attributes in mysql seems rather hard to do.unless of course there is a way to detect how manieth SUBSTRING_INDEX is the fitment or Fitment attribute - that would be the key to the ultimate solution.the update and select errors queries: UPDATE 6_serviceleads SET timestamp_ExpectedBy = CASE IF( INSTR( -- if QuoteMe (QM) else CanopyXchange (CX) text_LeadAttributes, "canopy_req" ) > 0, SUBSTRING_INDEX( -- get fitment attribute value for QM SUBSTRING_INDEX( text_LeadAttributes, "<br />", 4 ), " = ", -1 ), SUBSTRING_INDEX( -- get Fitment attribute value for CX SUBSTRING_INDEX( text_LeadAttributes, "<br />", -1 ), " = ", -1 ) ) WHEN "ASAP" THEN -- "ASAP" for both QM and CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 7 DAY ), "23:59:59" ) WHEN "within_2_weeks" THEN -- "within_2_weeks" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 14 DAY ), "23:59:59" ) WHEN "Within the next 2 weeks" THEN -- "Within the next 2 weeks" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 14 DAY ), "23:59:59" ) WHEN "within_month" THEN -- "within_month" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 30 DAY ), "23:59:59" ) WHEN "Within the next month" THEN -- "Within the next month" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 30 DAY ), "23:59:59" ) WHEN "within_2_months" THEN -- "within_2_months" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 60 DAY ), "23:59:59" ) WHEN "Within the next 2 months" THEN -- "Within the next 2 months" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 60 DAY ), "23:59:59" ) WHEN "within_3_months" THEN -- "within_3_months" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 90 DAY ), "23:59:59" ) WHEN "Within the next 3 months" THEN -- "Within the next 3 months" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 90 DAY ), "23:59:59" ) WHEN "not_within_3_months" THEN -- "not_within_3_months" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 120 DAY ), "23:59:59" ) WHEN "Not within the next 3 months" THEN -- "Not within the next 3 months" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 120 DAY ), "23:59:59" ) ELSE -- "0000-00-00 23:59:59" unmatched error TIMESTAMP( "0000-00-00 23:59:59" ) END;SELECT timestamp_LeadCreated, text_LeadAttributes, timestamp_ExpectedBy FROM 6_serviceleads WHERE timestamp_ExpectedBy < "2000-01-01 00:00:00" ORDER BY timestamp_LeadCreated DESC LIMIT 0, 34;
  7. ok the leadattributes field differs as follows from the two sources:QuoteME SELECT CASE IF( INSTR( -- if QuoteMe (QM) else CanopyXchange (CX) text_LeadAttributes, "canopy_req" ) > -1, TRIM( SUBSTRING_INDEX( -- get fitment attribute value for QM SUBSTRING_INDEX( text_LeadAttributes, "<br />", 4 ), " = ", -1 ) ), TRIM( SUBSTRING_INDEX( -- get Fitment attribute value for CX SUBSTRING_INDEX( text_LeadAttributes, "<br />", -1 ), " = ", -1 ) ) ) WHEN "ASAP" THEN -- "ASAP" for both QM and CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 7 DAY ), "23:59:59" ) WHEN "within_2_weeks" THEN -- "within_2_weeks" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 14 DAY ), "23:59:59" ) WHEN "Within the next 2 weeks" THEN -- "Within the next 2 weeks" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 14 DAY ), "23:59:59" ) WHEN "within_month" THEN -- "within_month" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 30 DAY ), "23:59:59" ) WHEN "Within the next month" THEN -- "Within the next month" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 30 DAY ), "23:59:59" ) WHEN "within_2_months" THEN -- "within_2_months" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 60 DAY ), "23:59:59" ) WHEN "Within the next 2 months" THEN -- "Within the next 2 months" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 60 DAY ), "23:59:59" ) WHEN "within_3_months" THEN -- "within_3_months" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 90 DAY ), "23:59:59" ) WHEN "Within the next 3 months" THEN -- "Within the next 3 months" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 90 DAY ), "23:59:59" ) WHEN "not_within_3_months" THEN -- "not_within_3_months" for QM TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 120 DAY ), "23:59:59" ) WHEN "Not within the next 3 months" THEN -- "Not within the next 3 months" for CX TIMESTAMP( DATE_ADD( SUBSTRING_INDEX( timestamp_LeadCreated, " ", 1 ), INTERVAL 120 DAY ), "23:59:59" ) ELSE -- "0000-00-00 23:59:59" unmatched error TIMESTAMP( "0000-00-00 23:59:59" ) END AS timestamp_ExpectedOn, text_LeadAttributes, timestamp_LeadCreated FROM 6_serviceleads ORDER BY timestamp_LeadCreated DESC LIMIT 0, 4817; i've modified this to exactly use the delimiters specified in the database, but i don't get a case match for the CX leads i beieve there is something wrong with my case VALUE statement (currently using an if function). could somebody please help?
  8. ok the query has been updated again: UPDATE 6_serviceleads SET timestamp_ExpectedBy = CASE IF( INSTR( -- if QuoteMe (QM) else CanopyXchange (CX) text_LeadAttributes, "canopy_req" ) > -1, SUBSTRING_INDEX( -- get fitment attribute value for QM SUBSTRING_INDEX( SUBSTRING_INDEX( 6_serviceleads.text_LeadAttributes, '<br />', 4 ), ';', -1 ), ' = ', -1 ), SUBSTRING_INDEX( -- get Fitment attribute value for CX SUBSTRING_INDEX( SUBSTRING_INDEX( 6_serviceleads.text_LeadAttributes, '<br />', 6 ), ';', -1 ), ' = ', -1 ) ) WHEN "ASAP" THEN -- "ASAP" for both QM and CX TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 7 DAY, "23:59:59" ) WHEN "within_2_weeks" THEN -- "within_2_weeks" for QM TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 14 DAY, "23:59:59" ) WHEN "Within the next 2 weeks" THEN -- "Within the next 2 weeks" for CX TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 14 DAY, "23:59:59" ) WHEN "within_month" THEN -- "within_month" for QM TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 30 DAY, "23:59:59" ) WHEN "Within the next month" THEN -- "Within the next month" for CX TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 30 DAY, "23:59:59" ) WHEN "within_2_months" THEN -- "within_2_months" for QM TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 60 DAY, "23:59:59" ) WHEN "Within the next 2 months" THEN -- "Within the next 2 months" for CX TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 60 DAY, "23:59:59" ) WHEN "within_3_months" THEN -- "within_3_months" for QM TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 90 DAY, "23:59:59" ) WHEN "Within the next 3 months" THEN -- "Within the next 3 months" for CX TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 90 DAY, "23:59:59" ) WHEN "not_within_3_months" THEN -- "not_within_3_months" for QM TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 180 DAY, "23:59:59" ) WHEN "Not within the next 3 months" THEN -- "Not within the next 3 months" for CX TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 180 DAY, "23:59:59" ) ELSE -- timestamp with empty date = error TIMESTAMP("0000-00-00 23:59:59") END;SELECT timestamp_LeadCreated, text_LeadAttributes, timestamp_ExpectedBy FROM 6_serviceleads ORDER BY timestamp_LeadCreated DESC LIMIT 0, 4817; and something is most definately wrong in the way i add days to the date from the leadcreated timestamp: TIMESTAMP( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ) + INTERVAL 7 DAY, "23:59:59" ) how would be a better way to do it? adding 7, 14, 30, 60, 90 or 180 days to the date? and setting the time to 23:59:59 for a new timestamp.
  9. why would i need to use INNER JOIN though, its only updating a new field (timestamp_ExpectedBy) from another two fields (text_LeadAttributes and timestamp_LeadCreated) in the same table?
  10. ok this has been updated a bit by taking only the date part of the timestamp for LeadCreated.rather long query though 0o UPDATE 6_serviceleads SET timestamp_ExpectedBy = CASE IF( INSTR( -- if QuoteMe (QM) else CanopyXchange (CX) text_LeadAttributes, "canopy_req" ) > -1, SUBSTRING_INDEX( -- get fitment attribute value for QM SUBSTRING_INDEX( SUBSTRING_INDEX( 6_serviceleads.text_LeadAttributes, '<br />', 4 ), ';', -1 ), ' = ', -1 ), SUBSTRING_INDEX( -- get Fitment attribute value for CX SUBSTRING_INDEX( SUBSTRING_INDEX( 6_serviceleads.text_LeadAttributes, '<br />', 6 ), ';', -1 ), ' = ', -1 ) ) WHEN "ASAP" THEN -- "ASAP" for both QM and CX TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 7 DAY ), "23:59:59" ) WHEN "within_2_weeks" THEN -- "within_2_weeks" for QM TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 14 DAY ), "23:59:59" ) WHEN "Within the next 2 weeks" THEN -- "Within the next 2 weeks" for CX TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 14 DAY ), "23:59:59" ) WHEN "within_month" THEN -- "within_month" for QM TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 30 DAY ), "23:59:59" ) WHEN "Within the next month" THEN -- "Within the next month" for CX TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 30 DAY ), "23:59:59" ) WHEN "within_2_months" THEN -- "within_2_months" for QM TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 60 DAY ), "23:59:59" ) WHEN "Within the next 2 months" THEN -- "Within the next 2 months" for CX TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 60 DAY ), "23:59:59" ) WHEN "within_3_months" THEN -- "within_3_months" for QM TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 90 DAY ), "23:59:59" ) WHEN "Within the next 3 months" THEN -- "Within the next 3 months" for CX TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 90 DAY ), "23:59:59" ) WHEN "not_within_3_months" THEN -- "not_within_3_months" for QM TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 120 DAY ), "23:59:59" ) WHEN "Not within the next 3 months" THEN -- "Not within the next 3 months" for CX TIMESTAMP( DATE_ADD( DATE( SUBSTRING_INDEX( timestamp_LeadCreated, ' ', -1 ), INTERVAL 120 DAY ), "23:59:59" ) ELSE -- timestamp with empty date = error TIMESTAMP("0000-00-00 23:59:59") END;
  11. hi all,i have a query that i have to run to update a new field in the database according to the fitment or Fitment attributes that are already existing in the records. the attributes are all in a string eg w = x<br />y = zhere is my statement - it supposedly retrieves the fitment/Fitment attribute, then does a case when to get a different value depending on the value of the fitment/Fitment attribute. i hope the comments are explanatory enough UPDATE 6_serviceleads SET timestamp_ExpectedBy = CASE IF( INSTR(text_LeadAttributes,"canopy_req"), -- if QuoteMe (QM) else CanopyXchange (CX) SUBSTRING_INDEX( -- get fitment attribute value for QM SUBSTRING_INDEX( SUBSTRING_INDEX( 6_serviceleads.text_LeadAttributes, '<br />', 4 ), ';', -1 ), ' = ', -1 ), SUBSTRING_INDEX( -- get Fitment attribute value for CX SUBSTRING_INDEX( SUBSTRING_INDEX( 6_serviceleads.text_LeadAttributes, '<br />', 6 ), ';', -1 ), ' = ', -1 ) ) WHEN "ASAP" THEN -- "ASAP" for both QM and CX TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 7 DAY ), "23:59:59" ) WHEN "within_2_weeks" THEN -- "within_2_weeks" for QM TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 14 DAY ), "23:59:59" ) WHEN "Within the next 2 weeks" THEN -- "Within the next 2 weeks" for CX TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 14 DAY ), "23:59:59" ) WHEN "within_month" THEN -- "within_month" for QM TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 30 DAY ), "23:59:59" ) WHEN "Within the next month" THEN -- "Within the next month" for CX TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 30 DAY ), "23:59:59" ) WHEN "within_2_months" THEN -- "within_2_months" for QM TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 60 DAY ), "23:59:59" ) WHEN "Within the next 2 months" THEN -- "Within the next 2 months" for CX TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 60 DAY ), "23:59:59" ) WHEN "within_3_months" THEN -- "within_3_months" for QM TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 90 DAY ), "23:59:59" ) WHEN "Within the next 3 months" THEN -- "Within the next 3 months" for CX TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 90 DAY ), "23:59:59" ) WHEN "not_within_3_months" THEN -- "not_within_3_months" for QM TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 120 DAY ), "23:59:59" ) WHEN "Not within the next 3 months" THEN -- "Not within the next 3 months" for CX TIMESTAMP( DATE_ADD( DATE(timestamp_LeadCreated), INTERVAL 120 DAY ), "23:59:59" ) ELSE -- timestamp with empty date = error TIMESTAMP("0000-00-00 23:59:59") END; now it seems as if this query made the server crash. i would have to optimise it somehow, but i am not quite sure how. the expectedby timestamp is always by 23:59:59, the date depending on the fitment or Fitment attribute.any advise? any assistance perhaps?
  12. the attributes were being dropped from the $attribsarr array for the 3 distinct statement mailers (sent to suppliers with premium, trial and freemium status).it seems the problem was with the memory allocated to the php scripts in apache was used up / running low.
  13. this was repaired over all my on posts on saturday - i created a function to format the attributes as an array from a string passed as a parameter: function formattribs($str = "") { $str = preg_replace("/[\n\r]+/","//",$str); $ret = preg_split("/<[^>]+>/",$str,-1,PREG_SPLIT_NO_EMPTY); foreach ($ret as $value) { // contact name populate & supplier name in subject // make/model style // requirement & budfget // 3rde & 4de soos wat dit is $val = split(" = ",$value); $attribsarr[$val[0]] = $val[1]; } return $attribsarr;}
  14. haha yeah i get you there - i believe everything is possible with code. in time we'll even be able to steer boeings from websites 0ojust with the health problems its a bit harder than usual atm but i will always love coding
  15. ok generated a function now to convert the attributes into the array with named elements. $attribsarr = [color="#008000"][b]formattribs[/b][/color]($row1["text_LeadAttributes"]); $consumer = split(";",$row1["text_Consumer"]); $ret .= $attribsarr["products_description"].$attribsarr["vehicle_make_model"].((strlen($attribsarr["products_description"])==0)?" - ".$attribsarr["canopy_style"]:"")."<br />"; $ret .= $attribsarr["Requirement"].$attribsarr["canopy_req"]." - ".$attribsarr["Budget"].$attribsarr["budget"]."<br />"; $ret .= $consumer[0]." (".$consumer[1].", ".$consumer[2].")<br />". $row1["text_RegionDescription"]." (".$consumer[3].")"; unset($attribsarr); and $attribsarr = [color="#008000"][b]formattribs[/b][/color]($row["text_LeadAttributes"]); $consumer = split(";",$row["text_Consumer"]); $ret .= $attribsarr["products_description"].$attribsarr["vehicle_make_model"].((strlen($attribsarr["products_description"])==0)?" - ".$attribsarr["canopy_style"]:"")."<br />"; $ret .= $attribsarr["Requirement"].$attribsarr["canopy_req"]." - ".$attribsarr["Budget"].$attribsarr["budget"]."<br />"; $ret .= $consumer[0]." (".$consumer[1].", ".$consumer[2].")<br />". $row["text_RegionDescription"]." (".$consumer[3].")"; now to test if it works
  16. hi again...at the moment i am battling with the following piece of code: function gettransactions($s) { //= supplier id, >= from and <= to dates available create constraints // ".(($numargs>0)?" WHERE ":"").join(" AND ",$arg_list)." $arr = array(); if ($s > 0) { array_push($arr,"13_prospectleadsent.bigint_SupplierID = ".$GLOBALS["s"]); } array_push($arr,"13_prospectleadsent.timestamp_Sent >= \"".$GLOBALS["f"]."\""); array_push($arr,"13_prospectleadsent.timestamp_Sent <= \"".$GLOBALS["t"]."\""); $tsql = "SELECT 10_serviceprospects.bigint_ProspectID, 13_prospectleadsent.smallint_ProspectOrdinal, 13_prospectleadsent.timestamp_Sent, 10_serviceprospects.text_LeadAttributes, 10_serviceprospects.text_Consumer, 1_regions.text_RegionDescription, 2_servicescatalogue.text_ServiceDescription FROM 13_prospectleadsent LEFT JOIN 10_serviceprospects ON (13_prospectleadsent.bigint_ProspectID = 10_serviceprospects.bigint_ProspectID) LEFT JOIN 1_regions ON (10_serviceprospects.bigint_RegionID = 1_regions.bigint_RegionID) LEFT JOIN 2_servicescatalogue ON (10_serviceprospects.bigint_ServiceID = 2_servicescatalogue.bigint_ServiceID) WHERE ".join(" AND ",$arr)." ORDER BY 13_prospectleadsent.timestamp_Sent DESC;"; $result = mysql_query_errors($tsql , $conn , __FILE__ , __LINE__ , false); if ($result) { while ($row = mysql_fetch_array($result)) { $leadid = $row["bigint_ProspectID"]; $ordinal = $row["smallint_ProspectOrdinal"]; $ret .= " <tr>\n"; $ret .= " <td><div class=\"timestamps\">" . (($leadid>0)?"#".($leadid+9001100)."-".$ordinal."<br />":"") . $row["timestamp_Sent"] . "</div></td>\n"; $ret .= " <td><div class=\"transactions\">"; $attr = [b]preg_split[/b]("/<[^>]+>/","//",[b]preg_replace[/b]("/[\r\n]+/","//",$row["text_LeadAttributes"]),-1,PREG_SPLIT_NO_EMPTY); $attribsarr = array(); foreach ($attr as $key => $val) { // contact name populate & supplier name in subject // make/model style // requirement & budget // 3rde & 4de soos wat dit is // $val = split(" = ",$value); $attribsarr[$key] = $val; } $consumer = split(";",$row["text_Consumer"]); $ret .= [color="#FF0000"]$attribsarr["products_description"][/color].[color="#FF8C00"]$attribsarr["vehicle_make_model"][/color].((strlen([color="#FF0000"]$attribsarr["products_description"][/color])==0)?" - ".[color="#FF8C00"]$attribsarr["canopy_style"][/color]:"")."<br />"; $ret .= [color="#FF0000"]$attribsarr["Requirement"][/color].[color="#FF8C00"]$attribsarr["canopy_req"][/color]." - ".[color="#FF0000"]$attribsarr["Budget"][/color].[color="#FF8C00"]$attribsarr["budget"][/color]."<br />"; $ret .= $consumer[0]." (".$consumer[1].", ".$consumer[2].")<br />". $row["text_RegionDescription"]." (".$consumer[3].")"; $ret .= "</div></td>\n"; unset($attribsarr); } mysql_free_result($result); } return $ret;} now the problem is that in the statement e-mails, sales leads with the following styles of attribute sets: canopy_req = [color="#FF8C00"]new_white[/color]<br>canopy_style = [color="#FF8C00"]highline_standard[/color]<br>budget = [color="#FF8C00"]R3,000 to R4,000[/color]<br>fitment = [color="#FF8C00"]ASAP[/color]<br>vehicle_status = [color="#FF8C00"]possession_yes[/color]<br>vehicle_make_model = [color="#FF8C00"]Opel - Corsa[/color]<br>year_model = [color="#FF8C00"]2009[/color] and products_description = [color="#FF0000"]Tata D/C Canopy - Half Door[/color]<br>Bakkie model = [color="#FF0000"]2004 - current model[/color]<br>Requirement = [color="#FF0000"]New - White[/color]<br>Colour code = [color="#FF0000"]White Non-coded (standard)[/color]<br>Budget = [color="#FF0000"]R3,000 to R4,000[/color]<br>Fitment = [color="#FF0000"]ASAP[/color] keep getting the colored attributes in bold - dropped from display: and unfortunately at the moment all the $attribsarr elements (red and orange from the various sources) are being dropped.it seems to be that my preg_replace and preg_split functions have regular expressions with unexpected results in this piece of code - for the life of me, i cannot figure out why this is happening. any assistance asap would be greatly appreciated, so this issue can be resolved before the end of the weekend please :)i need to remove all possible line breaks and carriage returns, before splitting the string by all html tags. or both xhtml 1.0 and html 4.0 line break tags.
  17. function gettransactions($s) { //= supplier id, >= from and <= to dates available create constraints // ".(($numargs>0)?" WHERE ":"").join(" AND ",$arg_list)." $arr = array(); if ($s > 0) { array_push($arr,"13_prospectleadsent.bigint_SupplierID = ".$GLOBALS["s"]); } array_push($arr,"13_prospectleadsent.timestamp_Sent >= \"".$GLOBALS["f"]."\""); array_push($arr,"13_prospectleadsent.timestamp_Sent <= \"".$GLOBALS["t"]."\""); $tsql = "SELECT 10_serviceprospects.bigint_ProspectID, 13_prospectleadsent.smallint_ProspectOrdinal, 13_prospectleadsent.timestamp_Sent, 10_serviceprospects.text_LeadAttributes, 10_serviceprospects.text_Consumer, 1_regions.text_RegionDescription, 2_servicescatalogue.text_ServiceDescription FROM 13_prospectleadsent LEFT JOIN 10_serviceprospects ON (13_prospectleadsent.bigint_ProspectID = 10_serviceprospects.bigint_ProspectID) LEFT JOIN 1_regions ON (10_serviceprospects.bigint_RegionID = 1_regions.bigint_RegionID) LEFT JOIN 2_servicescatalogue ON (10_serviceprospects.bigint_ServiceID = 2_servicescatalogue.bigint_ServiceID) WHERE ".join(" AND ",$arr)." ORDER BY 13_prospectleadsent.timestamp_Sent DESC;"; $result = mysql_query_errors($tsql , $conn , __FILE__ , __LINE__ , false); if ($result) { while ($row = mysql_fetch_array($result)) { $leadid = $row["bigint_ProspectID"]; $ordinal = $row["smallint_ProspectOrdinal"]; $ret .= " <tr>\n"; $ret .= " <td><div class=\"timestamps\">" . (($leadid>0)?"#".($leadid+9001100)."-".$ordinal."<br />":"") . $row["timestamp_Sent"] . "</div></td>\n"; $ret .= " <td><div class=\"transactions\">"; $attr = preg_split("/<[^>]+>/","//",preg_replace("/[\r\n]+/","//",$row["text_LeadAttributes"]),-1,PREG_SPLIT_NO_EMPTY); $attribsarr = array(); foreach ($attr as $key => $val) { // contact name populate & supplier name in subject // make/model style // requirement & budget // 3rde & 4de soos wat dit is // $val = split(" = ",$value); $attribsarr[$key] = $val; } $consumer = split(";",$row["text_Consumer"]); $ret .= $attribsarr["products_description"].$attribsarr["vehicle_make_model"].((strlen($attribsarr["products_description"])==0)?" - ".$attribsarr["canopy_style"]:"")."<br />"; $ret .= $attribsarr["Requirement"].$attribsarr["canopy_req"]." - ".$attribsarr["Budget"].$attribsarr["budget"]."<br />"; $ret .= $consumer[0]." (".$consumer[1].", ".$consumer[2].")<br />". $row["text_RegionDescription"]." (".$consumer[3].")"; $ret .= "</div></td>\n"; unset($attribsarr); } mysql_free_result($result); } return $ret;}
  18. ahhhh *wana kick self*the problem was the $service variable and the extra $q parameter not being allowed for. this works now ^^
  19. hi,quite hard debugging this kind of thing - i can't seem to find the problem anywhere 0o. this is the manual mailer of statements, via ajax. absolutely no mails are being sent.it is called from the client by: makeRequest("POST", "scripts/ajax_transactions.php?q=2&s="+s+"&f="+f+"&t="+t, poststr); it returns a reload of the information. does not seem to perform the switch case for $q in the php.here is the php xml generator: <?php/*TRANSACTION MANAGER AJAX XML RESPONSEVersion 2.2.4*///set_time_limit(0);include("../includes/content/dwtphovu_f3rr37y.php");$q = $_GET["q"];if (is_numeric($q)) { if ($q > 1 || $q < 0) { $q = 0; }} else { $q = 0;}$s = $_GET["s"];if (!is_numeric($s)) { $s = 0;}$f = $_GET["f"];if (!strtotime(date($f))) { $f = date("Y-m-01 00:00:00");}$t = $_GET["t"];if (!strtotime(date($t))) { $t = date("Y-m-t 23:59:59");}include('../includes/statistical/timezones/class-timezone-conversion.php'); // Include timezone conversion classfunction convert_tz($timestamp, $timezone) { // convert local datetime to SAST (South African Standard Time) $tz = new TimezoneConversion(); // Create TimezoneConversion Object $tz->setProperty('DateTime', $timestamp); // Set local 'DateTime' to convert $tz->setProperty('Timezone', $timezone); // Set Timezone Convert To return $tz->convertDateTime(); // Get SAST Timestamp}$limit = "MANUAL";$now = getdate(strtotime(convert_tz(date("Y-m-d H:i:s", time()),"SAST")));$fs = strtotime(date("Y-m-1 00:00:00",mktime(0,0,0,$now["mon"]-3,1,$now["year"])));$fl = strtotime(date("Y-m-1 00:00:00",mktime(0,0,0,$now["mon"],1,$now["year"])));$ts = strtotime(date("Y-m-t 23:59:59",mktime(23,59,59,$now["mon"]+1,0,$now["year"])));$tl = strtotime(date("Y-m-t 23:59:59",mktime(23,59,59,$now["mon"]-2,0,$now["year"])));function getrecords($arr) { //if supplier id, >= from and <= to dates available create constraints // ".(($numargs>0)?" WHERE ":"").join(" AND ",$arg_list)." $sql = "SELECT * FROM 8_transactions".((count($arr)>0)?" WHERE ".join(" AND ",$arr):"")." ORDER BY bigint_TransactionID DESC;"; $result = mysql_query_errors($sql , $conn , __FILE__ , __LINE__ ); if ($result) { while ($row = mysql_fetch_array($result)) { echo " <transaction>\n"; echo " <transactionid>" . $row["bigint_TransactionID"] . "</transactionid>\n"; echo " <transactionevent>" . xmlentities($row["text_TransactionEvent"]) . "</transactionevent>\n"; if ($row["bigint_LeadID"]>0) { $sql1 = "SELECT * FROM 6_serviceleads JOIN (5_suppliers,2_servicescatalogue,1_regions) ON (6_serviceleads.bigint_SupplierID = 5_suppliers.bigint_SupplierID AND 6_serviceleads.bigint_ServiceID = 2_servicescatalogue.bigint_ServiceID AND 6_serviceleads.bigint_RegionID = 1_regions.bigint_RegionID) WHERE bigint_LeadID = ".$row["bigint_LeadID"].";"; $result1 = mysql_query_errors($sql1 , $conn , __FILE__ , __LINE__ ); if ($row1 = mysql_fetch_array($result1)) { $attr = split("<br />",$row1["text_LeadAttributes"]); foreach ($attr as $value) { $val = split(" = ",$value); if (stristr($val[0],"product")) { $req = trim($val[1]); } elseif (stristr($val[0],"make_model")) { $mak = trim($val[1]); } elseif (stristr($val[0],"style")) { $stl = trim($val[1]); } } if (strlen($req)==0) { $req = $mak." ".$stl; } echo " <makemodelstyle>" . xmlentities($req) . "</makemodelstyle>\n"; echo " <transactionconsumer>" . xmlentities($row1["text_Consumer"]) . "</transactionconsumer>\n"; echo " <transactionservice>" . xmlentities($row1["text_ServiceDescription"]) . "</transactionservice>\n"; echo " <transactionregion>" . xmlentities($row1["text_RegionDescription"]) . "</transactionregion>\n"; } } echo " <transactionamount>" . $row["bigint_TransactionAmount"] . "</transactionamount>\n"; echo " <transactionbalance>" . $row["bigint_TransactionBalance"] . "</transactionbalance>\n"; echo " <transactiontimestamp>" . $row["timestamp_TransactionEvent"] . "</transactiontimestamp>\n"; echo " </transaction>\n"; } }}function gettransactions() { $ret = ""; $sql = "SELECT * FROM 8_transactions WHERE bigint_SupplierID = ".$GLOBALS["s"]." AND timestamp_TransactionEvent >= \"".$GLOBALS["f"]."\" AND timestamp_TransactionEvent <= \"".$GLOBALS["t"]."\" ORDER BY bigint_TransactionID ASC;"; $result = mysql_query_errors($sql , $conn , __FILE__ , __LINE__ ); while ($row = mysql_fetch_array($result)) { $leadid = $row["bigint_LeadID"]; $ret .= " <tr>\n"; $ret .= " <td><div class=\"timestamps\">" . (($leadid>0)?"#".($leadid+11001000)."<br />":"") . $row["timestamp_TransactionEvent"] . "</div></td>\n"; $ret .= " <td><div class=\"transactions\">"; if ($leadid>0) { $sql1 = "SELECT * FROM 6_serviceleads JOIN (5_suppliers,2_servicescatalogue,1_regions) ON (6_serviceleads.bigint_SupplierID = 5_suppliers.bigint_SupplierID AND 6_serviceleads.bigint_ServiceID = 2_servicescatalogue.bigint_ServiceID AND 6_serviceleads.bigint_RegionID = 1_regions.bigint_RegionID) WHERE bigint_LeadID = ".$leadid.";"; $result1 = mysql_query_errors($sql1 , $conn , __FILE__ , __LINE__ ); if ($row1 = mysql_fetch_array($result1)) { $attr = split("<br />",$row1["text_LeadAttributes"]); $attribsarr = array(); foreach ($attr as $value) { // contact name populate & supplier name in subject // make/model style // requirement & budfget // 3rde & 4de soos wat dit is $val = split(" = ",$value); $attribsarr[$val[0]] = $val[1]; } $ret .= $attribsarr["products_description"].$attribsarr["vehicle_make_model"].((strlen($attribsarr["products_description"])==0)?" - ".$attribsarr["canopy_style"]:"")."<br />"; $ret .= $attribsarr["Requirement"].$attribsarr["canopy_req"]." - ".$attribsarr["Budget"].$attribsarr["budget"]."<br />"; $consumer = split(";",$row1["text_Consumer"]); $ret .= $consumer[0]." (".$consumer[1].", ".$consumer[2].")<br />". $row1["text_RegionDescription"]." (".$consumer[3].")"; } } else { $ret .= $row["text_TransactionEvent"]; } $ret .= "</div></td>\n"; $ret .= " <td><div class=\"amounts\">" . $row["bigint_TransactionAmount"] . "</div></td>\n"; $ret .= " <td><div class=\"balances\">" . $row["bigint_TransactionBalance"] . "</div></td>\n"; $ret .= " </tr>\n"; } echo $ret; return $ret;}function getsuppliers() { $sql = "SELECT * FROM 5_suppliers WHERE smallint_SupplierStatus = 0 ORDER BY text_SupplierName ASC;"; $result = mysql_query_errors($sql , $conn , __FILE__ , __LINE__ ); if ($result) { while ($row = mysql_fetch_array($result)) { echo " <supplier>\n"; echo " <id>".$row["bigint_SupplierID"]."</id>\n"; echo " <description>".$row["text_SupplierName"]."</description>\n"; if ($row["bigint_SupplierID"] == $GLOBALS["s"]) { echo " <selected>selected</selected>\n"; } echo " </supplier>\n"; } }}function monthadd($date, $month) { $now = getdate(strtotime(date("Y-m-d H:i:s", $date))); return strtotime(date("Y-m-1 00:00:00",mktime(0,0,0,$now["mon"]+$month,1,$now["year"])));}function monthsub($date, $month) { $now = getdate(strtotime(date("Y-m-d H:i:s", $date))); return strtotime(date("Y-m-t 23:59:59",mktime(23,59,59,$now["mon"]-$month+1,0,$now["year"])));}function getfromdates() { $f = $GLOBALS["fs"]; while ($f <= $GLOBALS["fl"]) { echo " <fromdate>\n"; echo " <text>1st ".date("F Y, H:i:s",$f)."</text>\n"; echo " <value>".date("Y-m-d H:i:s",$f)."</value>\n"; if (date("Y-m-d H:i:s",$f) == $GLOBALS["f"]) echo " <selected>selected</selected>\n"; echo " </fromdate>\n"; $f = monthadd($f,1); }}function gettodates() { $t = $GLOBALS["ts"]; while ($t >= $GLOBALS["tl"]) { echo " <todate>\n"; echo " <text>".date("tS F Y, H:i:s",$t)."</text>\n"; echo " <value>".date("Y-m-d H:i:s",$t)."</value>\n"; if (date("Y-m-d H:i:s",$t) == $GLOBALS["t"]) echo " <selected>selected</selected>\n"; echo " </todate>\n"; $t = monthsub($t,1); }}$response = "";header("Content-type: text/xml; charset=utf-8");echo "<?xml version=\"1.0\"?>\n";echo "<root>\n";switch ($q) { case 1: // supplier <-- mail statement // select supplier contact name and email address $sql = "SELECT 4_servicesuppliers.bigint_ServiceID, 5_suppliers.bigint_SupplierID, 5_suppliers.text_SupplierName, CONCAT(5_suppliers.text_ContactFirstName, \" \", 5_suppliers.text_ContactSurname) AS text_ContactFullName, 5_suppliers.`text_ContactE-mail`, 5_suppliers.text_AccMgr, 5_suppliers.`text_AccMgrE-mail` FROM 5_suppliers LEFT JOIN 4_servicesuppliers ON (5_suppliers.bigint_SupplierID = 4_servicesuppliers.bigint_SupplierID) WHERE 4_servicesuppliers.bigint_SupplierID = ".$GLOBALS["s"]." AND smallint_SupplierStatus = 0 GROUP BY 5_suppliers.bigint_SupplierID;"; $result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false); if ($result) { while ($row = mysql_fetch_array($result)) { include("../includes/mailer/class.phpmailer.php"); // include PHPMailer class $toname = $row["text_ContactFullName"]; $toaddr = $row["text_ContactE-mail"]; $recipient[0] = $toname; $recipient[1] = $row["text_SupplierName"]; $recipient[11] = $row["text_AccMgr"]; $recipient[12] = $row["text_AccMgrE-mail"]; // build mail and attempt sending, saving response $body = getFile("/home/dwtphovu/public_html/intellisource.co.za/prod_8347379386/templat/statement.html"); // load mail template $mail = new PHPMailer(); // create a new object $transactions = gettransactions($row["bigint_SupplierID"]); // build transactions html $body = populateflags($body); /*$body = str_replace("%MESSAGE%",$message,$body); // insert statement message $body = str_replace("%TRANSACTIONS%",$transactions,$body); // insert transaction records $body = str_replace("%FROMDATE%",date("jS F Y, H:i:s",strtotime($f)),$body); // insert from date $body = str_replace("%TODATE%",date("tS F Y, H:i:s",strtotime($t)),$body); // insert to date $body = str_replace("%LOGOURL%",$logourl,$body); // insert logo url $body = str_replace("%COPYRIGHT%","CanopyXchange",$body); // insert copyright owner $body = str_replace("%YEAR%",date("Y"),$body); // insert copyright year*/ require("/home/dwtphovu/public_html/intellisource.co.za/prod_8347379386/includes/mailer/dwtphovu_auth.php"); // include mailer auth $mail->From = "canopy@canopyxchange.za.net"; // set from email $mail->FromName = "CanopyXchange"; // set from name $mail->Subject = getSubText($body,"<title>","</title>"); // replacing to and from dates $mail->AddBCC("pierre@canopyxchange.za.net", "Pierre \"Greywacke\" du Toit"); // add the developer to the BCC list $mail->AddBCC($recipient[12], $recipient[11]); // add the account manager to the BCC list $mail->ClearAttachments(); // clears attachments $mail->MsgHTML($body); // set HTML Body $mail->AltBody = strip_tags(html_entity_decode(getSubText($body,"<body>","</body>"))); // set Text Body //$mail->AddAddress($toaddr, $toname); // add recipient $mail->IsHTML(true); // set send as HTML if(!$mail->Send()) { // if attempt sending failed $response = "FAILURE: ".$toname.", ".$toaddr." (".$mail->ErrorInfo.")"; // save error report } else { // else $response = "SUCCESS: ".$toname.", ".$toaddr; // save success report } // end if } } break; case 2: // acc manager <-- mail statement // select supplier contact name and email address $sql = "SELECT 4_servicesuppliers.bigint_ServiceID, 5_suppliers.bigint_SupplierID, 5_suppliers.text_SupplierName, CONCAT(5_suppliers.text_ContactFirstName, \" \", 5_suppliers.text_ContactSurname) AS text_ContactFullName, 5_suppliers.`text_ContactE-mail`, 5_suppliers.text_AccMgr, 5_suppliers.`text_AccMgrE-mail` FROM 5_suppliers LEFT JOIN 4_servicesuppliers ON (5_suppliers.bigint_SupplierID = 4_servicesuppliers.bigint_SupplierID) WHERE 4_servicesuppliers.bigint_SupplierID = ".$GLOBALS["s"]." AND smallint_SupplierStatus = 0 GROUP BY 5_suppliers.bigint_SupplierID;"; $result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false); if ($result) { while ($row = mysql_fetch_array($result)) { include("../includes/mailer/class.phpmailer.php"); // include PHPMailer class $toname = $row["text_AccMgr"]; $toaddr = $row["text_AccMgrE-mail"]; $recipient[0] = $toname; $recipient[1] = $row["text_SupplierName"]; $recipient[11] = $toname; $recipient[12] = $toaddr; // build mail and attempt sending, saving response $body = getFile("/home/dwtphovu/public_html/intellisource.co.za/prod_8347379386/templat/statement.html"); // load mail template $mail = new PHPMailer(); // create a new object $transactions = gettransactions($row["bigint_SupplierID"]); // build transactions html $body = populateflags($body); /*$body = str_replace("%MESSAGE%",$message,$body); // insert statement message $body = str_replace("%TRANSACTIONS%",$transactions,$body); // insert transaction records $body = str_replace("%FROMDATE%",date("jS F Y, H:i:s",strtotime($f)),$body); // insert from date $body = str_replace("%TODATE%",date("tS F Y, H:i:s",strtotime($t)),$body); // insert to date $body = str_replace("%LOGOURL%",$logourl,$body); // insert logo url $body = str_replace("%COPYRIGHT%","CanopyXchange",$body); // insert copyright owner $body = str_replace("%YEAR%",date("Y"),$body); // insert copyright year*/ require("/home/dwtphovu/public_html/intellisource.co.za/prod_8347379386/includes/mailer/dwtphovu_auth.php"); // include mailer auth $mail->From = "canopy@canopyxchange.za.net"; // set from email $mail->FromName = "CanopyXchange"; // set from name $mail->Subject = getSubText($body,"<title>","</title>"); // replacing to and from dates $mail->AddBCC("pierre@canopyxchange.za.net", "Pierre \"Greywacke\" du Toit"); // add the developer to the BCC list $mail->ClearAttachments(); // clears attachments $mail->MsgHTML($body); // set HTML Body $mail->AltBody = strip_tags(html_entity_decode(getSubText($body,"<body>","</body>"))); // set Text Body $mail->AddAddress($toname, $toaddr); // add recipient $mail->IsHTML(true); // set send as HTML if(!$mail->Send()) { // if attempt sending failed $response = "FAILURE: ".$toname.", ".$toaddr." (".$mail->ErrorInfo.")"; // save error report } else { // else $response = "SUCCESS: ".$toname.", ".$toaddr; // save success report } // end if } } break; default: // (re)load form}$arr = array();if ($s > 0) { array_push($arr,"bigint_SupplierID = ".$s);}array_push($arr,"timestamp_TransactionEvent >= \"".$f."\"");array_push($arr,"timestamp_TransactionEvent <= \"".$t."\"");getrecords($arr);getsuppliers();getfromdates();gettodates();if ($response) echo " <result>".$response."</result>\n";echo " <sql>".xmlentities(join("\n",$sql))."</sql>\n";echo "</root>";mysql_close($conn);?> this is supposed to show the result, but it does not even do that. something is causing it to end prematurely, how would i find out what that is if this page does not give any errors? it finds the supplier, by id 38 ($s = 38). it gets the transactions, and populates those values. it includes phpmailer, and the timezone conversion class.somebody please help! even with ideas on how to debug.
  20. well unfortunately this cannot be, notice that the timestamps differ. that is in the outer recordset. i have done the queries manually via PMA, and it selects as i expect them to.ps: my surgery has been postponed to admission on the 19th October, due to lack of support staff in the theatre.latest idea for a solution: why don't i combine the inner and outer select statements?unfortunately this is a bit hectic for me in my current mental incapacitation due to the dehydration problems so i would likely do this when i return from the hospital, along with some other things that are way above my head & too complicated for me to work on atm. unless of course, someone can help me with combining the select statements before the 19th.well temporarily reset the function to not use configurable texts, but rather "static" predefined values from the database. same recordsets, and it works. will resolve the configurable texts within a function once i got my focus and clarity on a constant level again.
  21. unfortunately freeing the inner result had no effect as follows: function gettransactions($s) { $ret = ""; $sql = "SELECT * FROM 8_transactions WHERE bigint_SupplierID = ".$s." AND timestamp_TransactionEvent >= \"".$GLOBALS["f"]."\" AND timestamp_TransactionEvent <= \"".$GLOBALS["t"]."\" ORDER BY bigint_TransactionID ASC;"; $result = mysql_query_errors($sql , $conn , __FILE__ , __LINE__ ); while ($row = mysql_fetch_array($result)) { $ret .= " <tr>\n"; $ret .= " <td><div class=\"timestamps\">" . $row["timestamp_TransactionEvent"] . "</div></td>\n"; $ret .= " <td><div class=\"transactions\">"; if ($row["bigint_LeadID"] > 0) { $sql1 = "SELECT * FROM 6_serviceleads JOIN (5_suppliers,2_servicescatalogue,1_regions) ON (6_serviceleads.bigint_SupplierID = 5_suppliers.bigint_SupplierID AND 6_serviceleads.bigint_ServiceID = 2_servicescatalogue.bigint_ServiceID AND 6_serviceleads.bigint_RegionID = 1_regions.bigint_RegionID) WHERE bigint_LeadID = ".$row["bigint_LeadID"].";"; $result1 = mysql_query_errors($sql1 , $conn , __FILE__ , __LINE__ , false); if ($result1) { if ($row1 = mysql_fetch_array($result1)) { unset($GLOBALS["leadid"]); unset($GLOBALS["consumerfullname"]); unset($GLOBALS["consumeremail"]); unset($GLOBALS["consumercell"]); unset($GLOBALS["city_town"]); unset($GLOBALS["regionname"]); unset($GLOBALS["attribsarr"]); unset($consumer); unset($attr); $consumer = explode(";",$row1["text_Consumer"]); $GLOBALS["leadid"] = $row["bigint_LeadID"]; $GLOBALS["consumerfullname"] = $consumer[0]; $GLOBALS["consumeremail"] = $consumer[1]; $GLOBALS["consumercell"] = $consumer[2]; $GLOBALS["city_town"] = $consumer[3]; $GLOBALS["regionname"] = $row1["text_RegionDescription"]; $attr = preg_split('/<[^>]+>/', $row1["text_LeadAttributes"], -1, PREG_SPLIT_NO_EMPTY); foreach ($attr as $value) { $val = explode(" = ",$value); $GLOBALS["attribsarr"][$val[0]] = $val[1]; } $ret1 = "%CONFIGTEXT Cron | Supplier | Transaction Detail%"; populateflags($ret1); $ret .= $ret1; } mysql_free_result($result1); } } else { $ret .= $row["text_TransactionEvent"]; } $ret .= "</div></td>\n"; $ret .= " <td><div class=\"balances\">" . $row["bigint_TransactionBalance"] . "</div></td>\n"; $ret .= " <td><div class=\"amounts\">" . $row["bigint_TransactionAmount"] . "</div></td>\n"; $ret .= " </tr>\n"; } return $ret;} the $GLOBALS variables need to be changed with each $result1 for each transaction because this is the only way i can see to pass values to the global populateflags function in the database include. how would i get this right?anyways - thanks for the help that was provided, and see you all in a week or two when i get outta hospital.
  22. but why are the first values being inserted every time the populateflags function is called? even in the second and rest of the loops? making the values "empty" did not do a thing.and unsetting them as follows before setting them, doesn't seem to do a thing either. function gettransactions($s) { $ret = ""; $sql = "SELECT * FROM 8_transactions WHERE bigint_SupplierID = ".$s." AND timestamp_TransactionEvent >= \"".$GLOBALS["f"]."\" AND timestamp_TransactionEvent <= \"".$GLOBALS["t"]."\" ORDER BY bigint_TransactionID ASC;"; $result = mysql_query_errors($sql , $conn , __FILE__ , __LINE__ ); while ($row = mysql_fetch_array($result)) { $ret .= " <tr>\n"; $ret .= " <td><div class=\"timestamps\">" . $row["timestamp_TransactionEvent"] . "</div></td>\n"; $ret .= " <td><div class=\"transactions\">"; if ($row["bigint_LeadID"] > 0) { $sql1 = "SELECT * FROM 6_serviceleads JOIN (5_suppliers,2_servicescatalogue,1_regions) ON (6_serviceleads.bigint_SupplierID = 5_suppliers.bigint_SupplierID AND 6_serviceleads.bigint_ServiceID = 2_servicescatalogue.bigint_ServiceID AND 6_serviceleads.bigint_RegionID = 1_regions.bigint_RegionID) WHERE bigint_LeadID = ".$row["bigint_LeadID"].";"; $result1 = mysql_query_errors($sql1 , $conn , __FILE__ , __LINE__ , false); if ($row1 = mysql_fetch_array($result1)) { unset($GLOBALS["leadid"]); unset($GLOBALS["consumerfullname"]); unset($GLOBALS["consumeremail"]); unset($GLOBALS["consumercell"]); unset($GLOBALS["city_town"]); unset($GLOBALS["regionname"]); unset($GLOBALS["attribsarr"]); unset($consumer); unset($attr); $consumer = explode(";",$row1["text_Consumer"]); $GLOBALS["leadid"] = $row["bigint_LeadID"]; $GLOBALS["consumerfullname"] = $consumer[0]; $GLOBALS["consumeremail"] = $consumer[1]; $GLOBALS["consumercell"] = $consumer[2]; $GLOBALS["city_town"] = $consumer[3]; $GLOBALS["regionname"] = $row1["text_RegionDescription"]; $attr = preg_split('/<[^>]+>/', $row1["text_LeadAttributes"], -1, PREG_SPLIT_NO_EMPTY); foreach ($attr as $value) { $val = explode(" = ",$value); $GLOBALS["attribsarr"][$val[0]] = $val[1]; } $ret1 = "%CONFIGTEXT Cron | Supplier | Transaction Detail%"; populateflags($ret1); $ret .= $ret1; } } else { $ret .= $row["text_TransactionEvent"]; } $ret .= "</div></td>\n"; $ret .= " <td><div class=\"balances\">" . $row["bigint_TransactionBalance"] . "</div></td>\n"; $ret .= " <td><div class=\"amounts\">" . $row["bigint_TransactionAmount"] . "</div></td>\n"; $ret .= " </tr>\n"; } return $ret;} maybe free $result1 too?
  23. okay the transaction text only is what it does not update for every record.why do the $GLOBALS variables not get updated with the outerloop loop of the recordset? the emails only repeat the first record's transaction information.ps: please - my focus and clarity should return with the ingrown & calcified stents being removed from my left renal ureter as soon as i am healed from the pcnl operation on the 12th october 2010. any help, even if just a nudge in the right direction asap would be extremely appreciated.
  24. ps: there are two cronjobs, one for weekly and one for monthly. the $f and $t are the only differentiating dates.here is also an example of the weekly cronjob mails being sent (it is in a tabular format though, unfortunately not supported by the forum): MY MOST SINCERE APOLOGIES FOR THE EXTENSIVE POSTS.
×
×
  • Create New...