Jump to content

Greywacke

Members
  • Posts

    510
  • Joined

  • Last visited

Everything posted by Greywacke

  1. okay... the alerted output is as follows: dropattribs(0) Continental Canopies (Cape Town) $GLOBALS["attribsarr"]["canopy_req"] = pre-owned_white $GLOBALS["attribsarr"]["canopy_style"] = lowline_luxury $GLOBALS["attribsarr"]["budget"] = R12,500 plus $GLOBALS["attribsarr"]["fitment"] = ASAP $GLOBALS["attribsarr"]["vehicle_status"] = possession_no_shopping $GLOBALS["attribsarr"]["vehicle_make_model"] = Toyota - LWB $GLOBALS["attribsarr"]["year_model"] = 2010 Just Canopies (Cape Town) $GLOBALS["attribsarr"]["canopy_req"] = pre-owned_white $GLOBALS["attribsarr"]["canopy_style"] = lowline_luxury $GLOBALS["attribsarr"]["budget"] = R12,500 plus $GLOBALS["attribsarr"]["fitment"] = ASAP $GLOBALS["attribsarr"]["vehicle_status"] = possession_no_shopping $GLOBALS["attribsarr"]["vehicle_make_model"] = Toyota - LWB $GLOBALS["attribsarr"]["year_model"] = 2010 Canopymart (Bellville) $GLOBALS["attribsarr"]["canopy_req"] = pre-owned_white $GLOBALS["attribsarr"]["canopy_style"] = lowline_luxury $GLOBALS["attribsarr"]["budget"] = R12,500 plus $GLOBALS["attribsarr"]["fitment"] = ASAP $GLOBALS["attribsarr"]["vehicle_status"] = possession_no_shopping $GLOBALS["attribsarr"]["vehicle_make_model"] = Toyota - LWB $GLOBALS["attribsarr"]["year_model"] = 2010 Roamer Rand Cape (Retreat) $GLOBALS["attribsarr"]["canopy_req"] = pre-owned_white[color="#FF0000"] $unset = false strpos("canopy_req","canopy_req") = 0 strpos("pre-owned_white","pre-owned_white") = 0[/color] $GLOBALS["attribsarr"]["canopy_style"] = lowline_luxury $GLOBALS["attribsarr"]["budget"] = R12,500 plus $GLOBALS["attribsarr"]["fitment"] = ASAP $GLOBALS["attribsarr"]["vehicle_status"] = possession_no_shopping $GLOBALS["attribsarr"]["vehicle_make_model"] = Toyota - LWB $GLOBALS["attribsarr"]["year_model"] = 2010 Stingray Canopies (Cape Town) $GLOBALS["attribsarr"]["canopy_req"] = pre-owned_white[color="#FF0000"] $unset = false strpos("canopy_req","canopy_req") = 0 strpos("pre-owned_white","pre-owned_white") = 0[/color] $GLOBALS["attribsarr"]["canopy_style"] = lowline_luxury $GLOBALS["attribsarr"]["budget"] = R12,500 plus $GLOBALS["attribsarr"]["fitment"] = ASAP $GLOBALS["attribsarr"]["vehicle_status"] = possession_no_shopping $GLOBALS["attribsarr"]["vehicle_make_model"] = Toyota - LWB $GLOBALS["attribsarr"]["year_model"] = 2010dropattribs(2)dropattribs(4) in the function as follows: function dropattribs($status) { switch ($status) { case 2: $sarray = "mailaddp"; // prospecting status 2 break; case 4: $sarray = "mailaddl"; // listed status 4 break; default: $sarray = "mailadds"; // active status 0 } echo mysql_real_escape_string("\r\ndropattribs(".$status.")"); for ($i = 0; $i < count($GLOBALS[$sarray]); $i++) { $sdata = $GLOBALS[$sarray][$i]; // get supplier data $arr = split(";;;",$sdata); // split supplier array $sid = $arr[6]; // get supplier id echo mysql_escape_string("\r\n\t".$arr[1]); foreach ($GLOBALS["attribsarr"] as $key => $value) { // begin iterate form attributes $unset = false; // reset the unset flag // select current attribute key and bound values for supplier that are not supported $tsql = "SELECT 3_serviceattributes.text_AttributeDescription, 3_serviceattributes.text_AttributeValue FROM 9_supplierattributes LEFT JOIN ( 3_serviceattributes ) ON ( 9_supplierattributes.bigint_AttributeID = 3_serviceattributes.bigint_AttributeID ) WHERE 3_serviceattributes.text_AttributeDescription LIKE \"%".strtolower($key)."%\" AND 3_serviceattributes.text_AttributeValue LIKE \"%".strtolower($value)."%\" AND 9_supplierattributes.bigint_ServiceID = ".$GLOBALS["service"]." AND 9_supplierattributes.bigint_RegionID = ".$GLOBALS["region"]." AND 9_supplierattributes.bigint_SupplierID = ".$sid.";"; $result = mysql_query_errors($tsql, $conn , __FILE__ , __LINE__ , false); echo mysql_real_escape_string("\r\n\t\t\$GLOBALS[\"attribsarr\"][\"".$key."\"] = ".$value); if ($result) { // begin if mysql result while ($row = mysql_fetch_array($result)) { // begin while suppliers !attribs // begin if db key and value in attrib key and value //echo mysql_real_escape_string("\r\n\t\t\t\$unset = ".(($unset===true)?"true":"false")); //echo mysql_real_escape_string("\r\n\t\t\tstrpos"); // echo mysql_real_escape_string("(\"".$key."\",\"".$row["text_AttributeDescription"]."\") = "); // echo mysql_real_escape_string((strpos(strtolower($key),strtolower($row["text_AttributeDescription"]))!==false)? // strpos(strtolower(trim($key)),strtolower($row["text_AttributeDescription"])):"false"); //echo mysql_real_escape_string("\r\n\t\t\tstrpos"); // echo mysql_real_escape_string("(\"".$value."\",\"".$row["text_AttributeValue"]."\") = "); // echo mysql_real_escape_string((strpos(strtolower($value),strtolower($row["text_AttributeValue"]))!==false)? // strpos(strtolower(trim($value)),strtolower($row["text_AttributeValue"])):"false");[color="#FF0000"] if (!$unset && // if hasn't unset yet strpos(strtolower(trim($key)), // if key does not exist in db strtolower(strval($row["text_AttributeDescription"]))) !== false && // " strpos(strtolower(trim($value)), // if value does not exist in db strtolower(strval($row["text_AttributeValue"]))) !== false) { // " [color="#9932CC"]unset($GLOBALS[$sarray][$i]); // drop the supplier from the array[/color] $unset = true; // set unset flag to true } // end if key & value in db[/color] } // end while suppliers !attributes mysql_free_result($result); // free mysql result after looping } // end if mysql result } // end iterate form attributes } // end iterate suppliers array} i have commented the echo'ing code which is then displayed as the abovementioned javascript alert, but it does not drop all the unmatched suppliers from the first array (active suppliers, status 0). the code in red is what does not seem to be happening when it should. any ideas? the line in purple is supposed to be unset if this condition is met, it is met twice as proven by the values alerted.
  2. hmmm i attempted to print as follows: echo mysql_real_escape_string("\r\n\t\t\t\$unset = ".(($unset===true)?"true":"false"));echo mysql_real_escape_string("\r\n\t\t\tstr");echo mysql_real_escape_string("pos(\"".$key."\",\"".$row["text_AttributeDescription"]."\") = ".((strpos(strtolower($key),strtolower($row["text_AttributeDescription"])))!==false)?strpos(strtolower(trim($key)),strtolower($row["text_AttributeDescription"])):"false");echo mysql_real_escape_string("\r\n\t\t\t\str");echo mysql_real_escape_string("pos(\"".$value."\",\"".$row["text_AttributeValue"]."\") = ".((strpos(strtolower($value),strtolower($row["text_AttributeValue"])))!==false)?strpos(strtolower(trim($value)),strtolower($row["text_AttributeValue"])):"false"); but this prints the following: :/this is returned in a javascript alert - hence the oneline echo'ing.
  3. sighs...trying to print the data that is checked, i ran into the following problem. echo mysql_real_escape_string("\r\n\t\t\t\$unset = ".(($unset===true)?"true":"false"));echo mysql_real_escape_string("\r\n\t\t\tstr"."pos(\"".$key."\",\"".$row["text_AttributeDescription"]."\") = ". ((strpos(strtolower(trim($key)),strtolower(strval($row["text_AttributeDescription"]))))!==false)? strpos(strtolower(trim($key)),strtolower(strval($row["text_AttributeDescription"]))):"false");echo mysql_real_escape_string("\r\n\t\t\t\str"."pos(\"".$value."\",\"".$row["text_AttributeValue"]."\") = ". ((strpos(strtolower(trim($value)),strtolower(strval($row["text_AttributeValue"]))))!==false)? strpos(strtolower(trim($value)),strtolower(strval($row["text_AttributeValue"]))):"false"); currently returns with the following: but i would like to have it print something like the following: how can one print a function name without executing it in a string?
  4. PS: thanks though for pointing in the right direction strpos instead of stristr truly seems to do the trick
  5. yeah i started noticing that stristr was in fact returning empty strings and not false - as even when the output is printed within the strval function, i get an empty string.basically i need to see if the database values (non-attribute pair) are within the the key and value pairs - case insensitive though - from the consumer who submitted the form. so rather do !="" ?
  6. okay, i can give some clarity on all data entered into the database.it is entered via ajax post requests, in unicode - now all unicode characters enter the database as utf8, the attribute values were originally ascii (no utf8 characters and apparently still are). it was needed to choose this collation rather than utf8_cirillic_ci, as this is the only one which is case sensitive according to certain sources i had discovered. tomorrow i am to run tests untill all the suppliers have a last sent lead date in the database (currently some have 0000-00-00 00:00:00 as the timestamp, also renaming the suppliers. my client said that he noticed the suppliers swapping not having the anti-attribute pairs matched when he renamed some of the suppliers.i am more importantly going to write all the keys and values checked - to see what is happening. is that if statement correct there with the stristr function? to see if the database anti-attribute keys and values exist within the consumer supplied keys and values.i've tested all the sql statements - and these all run smoothly with recordsets. if there is a recordset returned, then the supplier will only be dropped if the key and value in the database are in a key and value pair submitted by the consumer.will let more be known once the test runs have been done tomorrow.there are no errors, sql or php from what i can see - it is just an anomaly that only one supplier out of 5 for the region is dropped according to anti-attributes. these records are what are selected in the dropattribs function's 2-table joined select.it's just that the code i pasted seems to be behaving rather funky, not as it is supposed to.sincerely,Pierre du Toit.
  7. hi...in the mysql database, these attribute keys and values are stored as utf8_bin - but the data was entered as ascii - is it possible that a value cannot be matched due to the conversion of collation? there is a dash in some values and these are where it messes up. i notice that there are about 5 dash characters in utf8 - two lengths which can be confused. i am at a total loss here, i have absolutely no concrete clue as to why this would be happening.i believe the problem is with the dropattribs function, which drops suppliers retrieved into an array from the array - if an attribute unsupported by the supplier is found in the consumer data from the form.in the following function it iterates the attributes from the consumer, and depending on the supplier status to be checked - gets which supplier array it should iterate. it then iterates the consumer attributes, selecting the unsupported attributes for the supplier, and checking each of them for each iteration of consumer attributes. if a consumer has two or more unsupported attributes, then the flag was marked on dropping the supplier at the first iteration - and no more drops will occur for that supplier. is there perhaps a way that this function can be optimised? i am also looking for possible solutions as to why some suppliers are not dropped by non-attributes. after a few weeks of searching the net, i can't seem to come upon a logical explanation of why this is happening... function dropattribs($status) { switch ($status) { case 2: $sarray = "mailaddp"; // prospecting status 2 break; case 4: $sarray = "mailaddl"; // listed status 4 break; default: $sarray = "mailadds"; // active status 0 } for ($i = 0; $i < count($GLOBALS[$sarray]); $i++) { $sdata = $GLOBALS[$sarray][$i]; // get supplier data $arr = split(";;;",$sdata); // split supplier array $sid = $arr[6]; // get supplier id foreach ($GLOBALS["attribsarr"] as $key => $value) { // begin iterate form attributes $unset = false; // reset the unset flag for this iteration // select current attribute key and bound values for supplier that are not supported $tsql = "SELECT 3_serviceattributes.text_AttributeDescription, 3_serviceattributes.text_AttributeValue FROM 9_supplierattributes JOIN (3_serviceattributes) ON (9_supplierattributes.bigint_AttributeID = 3_serviceattributes.bigint_AttributeID) WHERE 9_supplierattributes.bigint_ServiceID = ".$GLOBALS["service"]." AND 9_supplierattributes.bigint_RegionID = ".$GLOBALS["region"]." AND 9_supplierattributes.bigint_SupplierID = ".$sid.";"; $result = mysql_query_errors($tsql, $conn , __FILE__ , __LINE__ , false); if ($result) { // begin if mysql result while ($row = mysql_fetch_array($result)) { // begin while suppliers !attribs // begin if db key and value in attrib key and value if (!$unset && stristr(trim($key),strval($row["text_AttributeDescription"])) != false && // if !unset & key & value in supplier !attribute stristr(trim($value),strval($row["text_AttributeValue"])) != false) { // " unset($GLOBALS[$sarray][$i]); // drop the supplier from the array $unset = true; // set unset flag to true } // end if key & value in supplier !attribute } // end while suppliers !attributes mysql_free_result($result); // free mysql result after looping } // end if mysql result } // end iterate form attributes } // end iterate suppliers array} the various supplier arrays are populated by the following function: function getsuppliers($sid,$status) { switch ($status) { case 2: $sarray = "mailaddp"; break; case 4: $sarray = "mailaddl"; break; default: $sarray = "mailadds"; } $GLOBALS[$sarray] = array(); // try check for all attributeid's within loop for supplier // make possible values == 0 (active), 2 (prospecting) or 4 (listed) $sql1 = "SELECT 5_suppliers.text_ContactFirstName, 5_suppliers.text_ContactSurname, 5_suppliers.text_SupplierName, 5_suppliers.`text_ContactE-mail`, 5_suppliers.bigint_CurrentBalance, 5_suppliers.bigint_ContactTel, 5_suppliers.text_SupplierAddress, 5_suppliers.bigint_SupplierID, 5_suppliers.text_GoogleMapsURL, 5_suppliers.text_VTigerData, 5_suppliers.tinyint_VariablePricingEnabled, 5_suppliers.smallint_SupplierStatus, 4_servicesuppliers.timestamp_LastLeadSentDate FROM 5_suppliers LEFT JOIN ( 4_servicesuppliers ) ON ( 4_servicesuppliers.bigint_SupplierID = 5_suppliers.bigint_SupplierID ) WHERE CURRENT_TIMESTAMP >= 5_suppliers.timestamp_DateStart AND CURRENT_TIMESTAMP <= 5_suppliers.timestamp_DateEnd AND 5_suppliers.smallint_SupplierStatus = ".$status." AND 4_servicesuppliers.bigint_ServiceID = ".$sid." AND 4_servicesuppliers.bigint_RegionID = ".$GLOBALS["region"]." ORDER BY 4_servicesuppliers.timestamp_LastLeadSentDate ASC;"; $result1 = mysql_query_errors($sql1, $conn , __FILE__ , __LINE__ , true); if ($result1) { while ($row1 = mysql_fetch_array($result1)) { $servicecost = costbycategory($GLOBALS["service"],$GLOBALS["attribsarr"],$row1["tinyint_VariablePricingEnabled"]); if (!str_in_array(";;;".$row1["text_SupplierName"].";;;",$GLOBALS[$sarray]) && (($status==2||$status==4)?true:($row1["bigint_CurrentBalance"] >= $servicecost))) { array_push($GLOBALS[$sarray], xmlentities($row1["text_ContactFirstName"]." ".$row1["text_ContactSurname"]).";;;".$row1["text_SupplierName"].";;;".$row1["text_ContactE-mail"].";;;".$row1["bigint_CurrentBalance"].";;;".$row1["bigint_ContactTel"].";;;".$row1["text_SupplierAddress"].";;;".$row1["bigint_SupplierID"].";;;".$row1["text_GoogleMapsURL"].";;;".$row1["text_VTigerData"].";;;".$row1["tinyint_VariablePricingEnabled"].";;;".$row1["smallint_SupplierStatus"]); } } mysql_free_result($result1); }} all text fields in the database are of utf8_binary collation - so as to case sensitively support utf8.somebody please help!- Pierre.
  8. well unfortunately that function cannot be used in that context (inside the unset function). it was generating an error - so i had to revert to using indices - i discovered the congruency. it was looping all records in the database, so if the consumer entered more than one attribute unsupported by the supplier - it deleted a supplier for each key and value matched against that supplier. i added a check, that only allows one supplier to be deleted no matter how many attributes it does not support. ^^ this issue has been resolved
  9. hi there,i receive the following error: Line 89 being:unset(current($GLOBALS[$sarray])); $sarray is set at the start of the function as follows, depending on the page level array that must be deleted from: function dropattribs($status) { switch ($status) { case 2: $sarray = "mailaddp"; break; case 4: $sarray = "mailaddl"; break; default: // 0 $sarray = "mailadds"; } foreach ($GLOBALS[$sarray] as $sdata) { // begin iterate suppliers array $arr = split(";;;",$sdata); // split supplier array $sid = $arr[6]; // get supplier id foreach ($GLOBALS["attribsarr"] as $key => $value) { // begin iterate form attributes // select current attribute key and bound values for supplier that are not supported $tsql = "SELECT 3_serviceattributes.text_AttributeDescription, 3_serviceattributes.text_AttributeValue FROM 9_supplierattributes JOIN (3_serviceattributes) ON (9_supplierattributes.bigint_AttributeID = 3_serviceattributes.bigint_AttributeID) WHERE 9_supplierattributes.bigint_ServiceID = ".$GLOBALS["service"]." AND 9_supplierattributes.bigint_RegionID = ".$GLOBALS["region"]." AND 9_supplierattributes.bigint_SupplierID = ".$sid.";"; $result = mysql_query_errors($tsql, $conn , __FILE__ , __LINE__ , false); if ($result) { // begin if mysql result while ($row = mysql_fetch_array($result)) { // begin while suppliers !attribs // begin if attrib key and value in db key and value if (stristr($key,strval($row["text_AttributeDescription"])) != false && stristr($value,strval($row["text_AttributeValue"])) != false) { // drop current $i from $mailadds/p/l array unset(current($GLOBALS[$sarray])); } // end if attrib key = db key } // end while suppliers !attributes mysql_free_result($result); } // end if mysql result } // end iterate form attributes } // end iterate suppliers array} somebody please help, these incongruencies need to be solved today - i have searched the net, but i can't seem to find a solution for this error when using unset to drop an array element.
  10. this issue has been resolved - that last bit of code works. turned out the Ref Id hidden field was to be left as a space, my client tried to insert the lead id there...
  11. not using sms'that function that i am trying works - only the server side handlers are a bit messed up.i keep getting response as "Duplicate" when emulating the HTML forms they provide.tried the form on www.leads360.com, and i get the following html: <html> <head> <title>Object reference not set to an instance of an object.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style> </head> <body bgcolor="white"> <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> <h2> <i>Object reference not set to an instance of an object.</i> </h2></span> <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br><br> <b> Exception Details: </b>System.NullReferenceException: Object reference not set to an instance of an object.<br><br> <b>Source Error:</b> <br><br> <table width=100% bgcolor="#ffffcc"> <tr> <td> <code><pre>Line 25: base.OnInit(e);Line 26: Page.ClientScript.RegisterClientScriptResource(typeof(FieldItemDropDownList), "Leads360.Express.WebControls.Controls.js");<font color=red>Line 27: this.BuildForm(this.CurrentOrg.Sector, placeHolder);</font>Line 28: }Line 29: </pre></code> </td> </tr> </table> <br> <b> Source File: </b> c:\Inetpub\wwwroot\Express\Web\SourcesHtmlForm.aspx.cs<b> Line: </b> 27 <br><br> <b>Stack Trace:</b> <br><br> <table width=100% bgcolor="#ffffcc"> <tr> <td> <code><pre>[NullReferenceException: Object reference not set to an instance of an object.] Leads360.Express.Web.SourcesHtmlForm.OnInit(EventArgs e) in c:\Inetpub\wwwroot\Express\Web\SourcesHtmlForm.aspx.cs:27 System.Web.UI.Control.InitRecursive(Control namingContainer) +321 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +834</pre></code> </td> </tr> </table> <br> <hr width=100% size=1 color=silver> <b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.1873; ASP.NET Version:2.0.50727.1433 </font> </body></html><!-- [NullReferenceException]: Object reference not set to an instance of an object. at Leads360.Express.Web.SourcesHtmlForm.OnInit(EventArgs e) in c:\Inetpub\wwwroot\Express\Web\SourcesHtmlForm.aspx.cs:line 27 at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)[HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.web_sourceshtmlform_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\8f766d84\170faff6\App_Web_vzsyz8nv.0.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)--><!-- This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments.--> this is probably due to this field being omitted, but how would i send a value containing an = or & in a post str? guessing urlencode... <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMjA4ODgwMjIyD2QWAgIDD2QWBAIDD2QWBAIDD2QWAgIBDxYCHgRUZXh0BUtodHRwOi8vbG14LmxlYWRzMzYwLmNvbS93ZWIvU291cmNlc0h0bWxGb3JtLmFzcHg/Q2FtcGFpZ25JZD00MjU1Jk9yZ0lkPTYwNjhkAh0PEA8WBh4NRGF0YVRleHRGaWVsZAUFVGl0bGUeDkRhdGFWYWx1ZUZpZWxkBQVUaXRsZR4LXyFEYXRhQm91bmRnZBAVPAwtLSBTZWxlY3QgLS0CQUsCQUwCQVICQVoCQkMCQ0ECQ08CQ1QCREMCREUCRkwCR0ECSEkCSUECSUQCSUwCSU4CS0ECS1MCS1kCTEECTUECTUICTUQCTUUCTUkCTU4CTU8CTVMCTVQCTkMCTkQCTkUCTkgCTkoCTk0CTlYCTlkCT0gCT0sCT04CT1ICUEECUFICUkkCU0MCU0QCVEUCVE4CVFgCVUsCVVQCVkECVkMCVlQCV0ECV0kCV1YCV1kVPAACQUsCQUwCQVICQVoCQkMCQ0ECQ08CQ1QCREMCREUCRkwCR0ECSEkCSUECSUQCSUwCSU4CS0ECS1MCS1kCTEECTUECTUICTUQCTUUCTUkCTU4CTU8CTVMCTVQCTkMCTkQCTkUCTkgCTkoCTk0CTlYCTlkCT0gCT0sCT04CT1ICUEECUFICUkkCU0MCU0QCVEUCVE4CVFgCVUsCVVQCVkECVkMCVlQCV0ECV0kCV1YCV1kUKwM8Z2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZGQCBQ8UKwADZGUFCDAwMDEuMS4xZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQUIY2FsZW5kYXLm6W6MSvDTvXRCpZOUkHZMau8+aw==" />
  12. well the client has been pressing on the urgency of this matter, and it's debugging the previous method vs. learning to navigate cURL functions vs the following function: function do_post_request($url, $data, $optional_headers = null) { $params = array('http' => array( 'method' => 'post', 'content' => $data )); if ($optional_headers!== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problem with $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $url, $php_errormsg"); } return $response;} i will attempt this one instead.
  13. well, thats the thing - see how the url is specified for the call - i have no idea where that error comes from. i am trying to connect over http on port 80.i will start printing out what the code is doing, solong.
  14. hi,i see i can do this either by using cURL or the fsockopen function, but i don't seem to be getting anywhere. i've been trying various functions made available on the php.net page for the fsockopen function, but i end up getting HTTP 500 errors and what not. there seems to be a huge difference on opinion with regards to implementing this functionality using fsockopen... below is the code i've been using at the moment: function open_page($url,$f=1,$c=2,$r=0,$a=0,$cf=0,$pd=""){ global $oldheader; $url = str_replace("http://","",$url); if (preg_match("#/#","$url")){ $page = $url; $url = @explode("/",$url); $url = $url[0]; $page = str_replace($url,"",$page); if (!$page || $page == ""){ $page = "/"; } $ip = gethostbyname($url); }else{ $ip = gethostbyname($url); $page = "/"; } $open = fsockopen($ip, 80, $errno, $errstr, 60); if ($pd){ $send = "POST $page HTTP/1.0\r\n"; }else{ $send = "GET $page HTTP/1.0\r\n"; } $send .= "Host: $url\r\n"; if ($r){ $send .= "Referer: $r\r\n"; }else{ if ($_SERVER['HTTP_REFERER']){ $send .= "Referer: {$_SERVER['HTTP_REFERER']}\r\n"; } } if ($cf){ if (@file_exists($cf)){ $cookie = urldecode(@file_get_contents($cf)); if ($cookie){ $send .= "Cookie: $cookie\r\n"; $add = @fopen($cf,'w'); fwrite($add,""); fclose($add); } } } $send .= "Accept-Language: en-us, en;q=0.50\r\n"; if ($a){ $send .= "User-Agent: $a\r\n"; }else{ $send .= "User-Agent: {$_SERVER['HTTP_USER_AGENT']}\r\n"; } if ($pd){ $send .= "Content-Type: application/x-www-form-urlencoded\r\n"; $send .= "Content-Length: " .strlen($pd) ."\r\n\r\n"; $send .= $pd; }else{ $send .= "Connection: Close\r\n\r\n"; } fputs($open, $send); while (!feof($open)) { $return .= fgets($open, 4096); } fclose($open); $return = @explode("\r\n\r\n",$return,2); $header = $return[0]; if ($cf){ if (preg_match("/Set\-Cookie\: /i","$header")){ $cookie = @explode("Set-Cookie: ",$header,2); $cookie = $cookie[1]; $cookie = explode("\r",$cookie); $cookie = $cookie[0]; $cookie = str_replace("path=/","",$cookie[0]); $add = @fopen($cf,'a'); fwrite($add,$cookie,strlen($read)); fclose($add); } } if ($oldheader){ $header = "$oldheader<br /><br />\n$header"; } $header = str_replace("\n","<br />",$header); if ($return[1]){ $body = $return[1]; }else{ $body = ""; } if ($c === 2){ if ($body){ $return = $body; }else{ $return = $header; } } if ($c === 1){ $return = $header; } if ($c === 3){ $return = "$header$body"; } if ($f){ if (preg_match("/Location\:/","$header")){ $url = @explode("Location: ",$header); $url = $url[1]; $url = @explode("\r",$url); $url = $url[0]; $oldheader = str_replace("\r\n\r\n","",$header); $l = "Location:"; $oldheader = str_replace("Location:",$l,$oldheader); return open_page($url,$f,$c,$r,$a,$cf,$pd); }else{ return $return; } }else{ return $return; }}// prepare variables$post = $_POST;$arrname = split(" ",$post["contact_name"]);$url = "http://lmx.leads360.com/web/SourcesHtmlForm.aspx?CampaignId=4255&OrgId=6068"; // post action$f = 1; // 1 for header, 2 for body, 3 for both$c = 2; // 1 for header, 2 for body, 3 for both$r = "http://lmx.leads360.com/web/SourcesHtmlForm.aspx?CampaignId=4255&OrgId=6068"; // referrer$a = NULL; // user-agent$cf = NULL; // cookie file$pd = "firstNameTextBox=".$arrname[0]. // post data "&lastNameTextBox=".array_slice($arrname,1,count($arrname) - 1). "&companyTextBox=". "&address1TextBox=". "&address2TextBox=".$post["province"]. "&cityTextBox=".$post["city_town"]. "&stateDropDownList=". "&zipTextBox=". "&homePhoneTextBox=". "&workPhoneTextBox=". "&mobilePhoneTextBox=".$post["contact_cell"]. "&h="."&m="."$t=". "&emailTextBox=".$post["email"]. "$ssnTextBox=". "$dateOfBirthTextBox=". "&control112=".$post["canopy_req"]. "&control113=".$post["canopy_style"]. "&control114=".$post["budget"]. "&control115=".$post["fitment"]. "&control116=".$post["add_reqs"]. "&control329=".$post["vehicle_status"]. "&control330=".$post["vehicle_make_model"]. "&control331=".$post["year_model"]. "&control332=". "&control334=". "&control335=". "&control336=". "&control337=". "&control338=". "&control339=". "&control340=". "&control341=". "&control342=". "&control343=". "&control344=". "&control345=". "&control346=". "&control347=". "&control348=". "&control349=". "&control350=". "&control351=". "&control352=". "&control353=";// send post request$page = open_page($url,$f,$c,$r,$a,$cf,$pd);echo $page; however, i keep getting the following browser error: and the following error descriptions are dumped in the error log, with the last 2 being repeated till the error log size reaches 512mb: of course the last 3 errors are because the fsockopen function does not manage to pull through. i can't seem to locate any information on fixing this issue, perhaps the server is behind a proxy to access internet outside that network? i have been working on this and googling trying to find a solution since monday, but i cannot seem to get it to work.any ideas people?i have absolutely no idea how to do this with cURL and the internet is without results, at least for my search queries... (kinda makes me feel dumb )
  15. hi, been a while since on this issue - but it has been resolved by the isp. it turns out they did not carry all the mysql user permissions over to the new server.this issue is now resolved
  16. okay, i seem to have come up with the following for this function to work.i've rather gone through the attribute combinations, and see if the number of matched key and values are equal to the count of the pricing combination pulled from the consumer attribute array. if they are, then return that category price :)took some thinking this one 0o function costbycategory($sid,$attribsarr,$variablepricing) { if ($variablepricing == 0) { return $GLOBALS["fixedcost"]; } else { $consumercombo = array(); foreach ($attribsarr as $key->$val) { $sql = "SELECT 16_serviceattributegroups.bigint_ServiceID, 16_serviceattributegroups.bigint_AttributeKeyID, 3_serviceattributes.text_AttributeDescription FROM 16_serviceattributegroups JOIN 3_serviceattributes ON ( 16_serviceattributegroups. bigint_AttributeKeyID = 3_serviceattributes.bigint_AttributeID ) WHERE 16_serviceattributegroups.bigint_ServiceID = ".$sid." AND 3_serviceattributes.text_AttributeDescription = \"".$key."\";"; $result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false); if ($result) { if ($row = mysql_fetch_array($result)) { array_push( $consumercombo, array( $row["text_AttributeDescription"], $val ) ); } } } mysql_free_result($result); // step through attribute value combinations, comparing attribute // values with consumer attributes tracked from form above (calc // and compare max successful hits) $sql0 = "SELECT bigint_CombinationID FROM 15_categoryattributecombinations WHERE bigint_ServiceID = ".$sid." GROUP BY bigint_CombinationID ORDER BY bigint_CombinationID ASC;" $result0 = mysql_query_errors($sql0, $conn , __FILE__ , __LINE__ , false); while ($row0 = mysql_fetch_result($result0)) { $combocount = 0; $sql1 = "SELECT 14_pricecategories.bigint_CategoryPrice, 15_categoryattributecombinations. bigint_CombinationID, 3_serviceattributes.text_AttributeDescription, 3_serviceattributes.text_AttributeValue FROM 15_categoryattributecombinations LEFT JOIN 3_serviceattributes ON ( 15_categoryattributecombinations. bigint_AttributeValueID = 3_serviceattributes. bigint_AttributeID ) LEFT JOIN 14_pricecategories ON ( 15_categoryattributecombinations. bigint_CategoryID = 14_pricecategories. bigint_CategoryID ) WHERE 15_categoryattributecombinations. bigint_CombinationID = ".$row0[ "bigint_CombinationID" ]." ORDER BY 3_serviceattributes.text_AttributeDescription, 3_serviceattributes.text_AttributeValue ASC;"; $result1 = mysql_query_errors($sql1, $conn , __FILE__ , __LINE__ , false); while ($row1 = mysql_fetch_array($result1)) { foreach ($consumercombo as $key->$val) { if ($row1["text_AttributeDescription"] == $key && $row1["text_AttributeValue"] == $val) { $combocount++; } if ($consumercombo == count($clientcombo)) { return $row1["bigint_CategoryPrice"]; } } } } }} this issue seems to be resolved
  17. haha!just realised i had an unrequired loop going through all the client arrays.here is the function without the unrequired loop function costbycategory($sid,$attribsarr,$variablepricing) { if ($variablepricing == 0) { return $GLOBALS["fixedcost"]; } else { // step through attribute array, keeping attribute // keys and values in an array to check. $clientcombo = array(); foreach ($attribsarr as $key->$val) { $sql = "SELECT 16_serviceattributegroups.bigint_ServiceID, 16_serviceattributegroups.bigint_AttributeKeyID, 3_serviceattributes.text_AttributeDescription FROM 16_serviceattributegroups JOIN 3_serviceattributes ON ( 16_serviceattributegroups. bigint_AttributeKeyID = 3_serviceattributes.bigint_AttributeID ) WHERE 16_serviceattributegroups.bigint_ServiceID = ".$sid." AND 3_serviceattributes.text_AttributeDescription = \"".$key."\";"; $result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false); if ($result) { if ($row = mysql_fetch_array($result)) { array_push( $clientcombo, array( $row["text_AttributeDescription"], $val ) ); } } } mysql_free_result($result); // step through recordset, comparing attribute combinations and // keeping track of combination id's and category prices to keep // price $datbcomboid = 0; $datbctprice = 0; $servercombo = array; foreach ($pricingcombo as $arr) { $sql = "SELECT 14_pricecategories.bigint_ServiceID, 14_pricecategories.bigint_CategoryPrice, 15_categoryattributecombinations. bigint_CombinationID, 3_serviceattributes.text_AttributeDescription, 3_serviceattributes.text_AttributeValue FROM 14_pricecategories LEFT JOIN ( 15_categoryattributecombinations, 3_serviceattributes ) ON ( 14_pricecategories.bigint_ServiceID = 15_categoryattributecombinations. bigint_ServiceID AND 14_pricecategories.bigint_CategoryID = 15_categoryattributecombinations. bigint_CategoryID AND 15_categoryattributecombinations.bigint_ServiceID = 3_serviceattributes.bigint_AttributeServiceID AND 15_categoryattributecombinations. bigint_AttributeValueID = 3_serviceattributes.bigint_AttributeID ) WHERE 14_pricecategories.bigint_ServiceID = ".$sid." ORDER BY 15_categoryattributecombinations. bigint_CombinationID ASC, 3_serviceattributes.text_AttributeDescription ASC, 3_serviceattributes.text_AttributeValue ASC;"; $result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false); if ($result) { // i seem to be getting lost around here... :/ ****** while ($row = mysql_fetch_array($result)) { if ($row["text_AttributeDescription"] == $key) { if ($row["text_AttributeValue"] == $val) { if ($row["bigint_CombinationID"] == $datbcomboid && $row["bigint_AttributeID"] == $datbctprice) { $datbcomboid = $row[ "bigint_CombinationID" ]; $datbctprice = $row[ "bigint_CategoryPrice" ]; array_push( $servercombo, // realised i am stuck 0o ); } } } } // i seem to be getting lost around here... :/ ****** mysql_free_result($result); } }} i'm still a bit stuck though... here is what the second resultset looks like: [b]bigint_ServiceID[/b] [b]bigint_CategoryPrice[/b] [b]bigint_CombinationID[/b]1 20 111 20 111 20 111 20 111 20 111 20 111 30 171 30 171 30 171 30 171 30 171 30 171 30 231 30 231 30 231 30 231 30 231 30 23[b]text_AttributeDescription[/b] [b]text_AttributeValue[/b]Budget R12,500 plusFitment Within the next 2 weeksRequirement New - Whitebudget R12,500 pluscanopy_req new_whitefitment within_2_weeksBudget R12,500 plusFitment Within the next 2 weeksRequirement Pre-owned - Colour-codedbudget R12,500 pluscanopy_req pre-owned_colour_codedfitment within_2_weeksBudget R7,500 to R10,000Fitment Within the next 2 weeksRequirement New - Whitebudget R7,500 to R10,000canopy_req new_whitefitment within_2_weeks
  18. hi all,got a bit of a brainteaser here to work on...firstly, the prices are defined in the database 14_pricecategories.secondly, a group of attribute keys which the services price determining, attribute combinations consist of - exists as 16_serviceattributegroups.thirdly, the various attribute combinations were defined in 15_categoryattributecombinations.an attribute combination is the combined attribute values defined by 16_serviceattributegroups.i've written the following function, and managed to get the client's request into a multidimentional array of keys and values.the second part of the function, selects all the database entries available, and sorts them by combination id, attribute key and attribute value.i seem to have hit a mental block of sorts regarding how to locate the valid price and exiting the loops.here is the function i wrote sofar: function costbycategory($sid,$attribsarr,$variablepricing) { if ($variablepricing == 0) { return $GLOBALS["fixedcost"]; } else { // step through attribute array, keeping attribute // keys and values in an array to check. $clientcombo = array(); foreach ($attribsarr as $key->$val) { $sql = "SELECT 16_serviceattributegroups.bigint_ServiceID, 16_serviceattributegroups.bigint_AttributeKeyID, 3_serviceattributes.text_AttributeDescription FROM 16_serviceattributegroups JOIN 3_serviceattributes ON ( 16_serviceattributegroups. bigint_AttributeKeyID = 3_serviceattributes.bigint_AttributeID ) WHERE 16_serviceattributegroups.bigint_ServiceID = ".$sid." AND 3_serviceattributes.text_AttributeDescription = \"".$key."\";"; $result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false); if ($result) { if ($row = mysql_fetch_array($result)) { array_push( $clientcombo, array( $row["text_AttributeDescription"], $val ) ); } } } mysql_free_result($result); // step through recordset, comparing attribute combinations and // keeping track of combination id's and category prices to keep // price $datbcomboid = 0; $datbctprice = 0; $servercombo = array; foreach ($pricingcombo as $arr) { $sql = "SELECT 14_pricecategories.bigint_ServiceID, 14_pricecategories.bigint_CategoryPrice, 15_categoryattributecombinations. bigint_CombinationID, 3_serviceattributes.text_AttributeDescription, 3_serviceattributes.text_AttributeValue FROM 14_pricecategories LEFT JOIN ( 15_categoryattributecombinations, 3_serviceattributes ) ON ( 14_pricecategories.bigint_ServiceID = 15_categoryattributecombinations. bigint_ServiceID AND 14_pricecategories.bigint_CategoryID = 15_categoryattributecombinations. bigint_CategoryID AND 15_categoryattributecombinations. bigint_ServiceID = 3_serviceattributes.bigint_AttributeServiceID AND 15_categoryattributecombinations. bigint_AttributeValueID = 3_serviceattributes.bigint_AttributeID ) WHERE 14_pricecategories.bigint_ServiceID = ".$sid." ORDER BY 15_categoryattributecombinations. bigint_CombinationID ASC, 3_serviceattributes.text_AttributeDescription ASC, 3_serviceattributes.text_AttributeValue ASC;"; $result = mysql_query_errors($sql, $conn , __FILE__ , __LINE__ , false); if ($result) { foreach ($attribids as $key->$val) { // i seem to be getting lost around here... :/ ****** while ($row = mysql_fetch_array($result)) { if ($row["text_AttributeDescription"] == $key) { if ($row["text_AttributeValue"] == $val) { if ($row["bigint_CombinationID"] == $datbcomboid && $row["bigint_AttributeID"] == $datbctprice) { $datbcomboid = $row[ "bigint_"+ "CombinationID" ]; $datbctprice = $row[ "bigint_"+ "CategoryPrice" ]; array_push( $servercombo, // realised i'm stuck ); } } } } // i seem to be getting lost around here... :/ ****** } } mysql_free_result($result); } }} i know i need to return the price from this function, but i need to find it first. coould somebody please help?
  19. oh! i forgot completely about the top level array!that line should be: for (n = 0; n < arr[i][3].length; n++) { issue resolved
  20. hi there,i keep getting the following error when trying to parse the array if there is only one 2nd level element. the function is below, line 454 marked in bold:function addservices(arr) { var sel = document.getElementById("menu_service"); var sel = new Array(); for (i = 0; i < arr.length; i++) { if (arr[i][2]) { // dynamicaly create dropdowns for this services attribute combination, setting accesskey and tabindexes var lyr = document.getElementById("div_combination"); var p = lyr.firstChild; var sel = new Array(); var lbl = new Array(); [b]for (n = 0; n < arr[3].length; n++) {[/b] var lbl = document.createElement("label"); var sel = document.createElement("select"); lbl.setAttribute("for", arr[3][n][0]); sel.setAttribute("name", "valuecombo["+arr[3][n][0]+"]"); sel.setAttribute("id", "valuecombo["+arr[3][n][0]+"]"); var opt = document.createElement("option"); opt.text = "* Select " + lbl[n]; // dropdown description as text opt.value = "0"; // 0 as value opt.selected = true; try { sel.add(opt, null); // standards compliant; doesn't work in IE } catch(ex) { sel.add(opt); // IE only } for (var o = 2; o < arr[3][n].length; o++) { var optdata = arr[3][n][o].split(";.;"); var opt = document.createElement("option"); opt.text = optdata[1]; // attribute value as text opt.value = optdata[0]; // attribute value id as value try { sel.add(opt, null); // standards compliant; doesn't work in IE } catch(ex) { sel.add(opt); // IE only } } p.appendChild(lbl); p.appendChild(sel); } } var opt = document.createElement('option'); opt.text = arr[i][1]; // service description opt.value = collapse(arr[i]); // save array as value opt.selected = (arr[i][2])?true:false; // selected option try { sel.add(opt, null); // standards compliant; doesn't work in IE } catch(ex) { sel.add(opt); // IE only } }} there is supposed to be support for multiple services, though at this stage there is only one. the multidimentional array is as follows, with ;;;; being primary seperators, ;;; secondary seperators: // get services information var services = xmldoc.getElementsByTagName("services"); for (var r = 0; r < services.length; r++) { var i = 0; var arr = new Array(); for (var s = 0; s < services[r].childNodes.length; s++) { var svc = services[r].childNodes[s]; if (svc.nodeName == "service" && svc.attributes) { arr[i] = new Array(); for (var a = 0; a < svc.attributes.length; a++) { arr[i][a] = svc.attributes[a].value; } for (var b = 0; b < svc.childNodes.length; b++) { var sel = svc.childNodes[b]; var z = arr[i].length; if (sel.attributes) { arr[i][z] = new Array(); for (var d = 0; d < sel.attributes.length; d++) { arr[i][z][d] = sel.attributes[d].value; } } } i++; } } //salert(arrs); addservices(arr); } any help would be greatly appreciated!
  21. had a look at using JSON, but i believe it would be better for a solution if i simplify the xml even more - as follows: <?xml version="1.0" encoding="UTF-8" ?><root> <pricecat> <catid>1</catid> <svcid>1</svcid> <catdesc>Category A</catdesc> <catprice>20</catprice> <validattrval combo="1" avid="397" ak="budget" av="R10,000 to R12,500" /> <validattrval combo="1" avid="1" ak="canopy_req" av="new_white" /> </pricecat> <services> <service id="1" name="Bakkie Canopy" selected="selected"> <select id="531" key="Budget" option527="527;.;R10,000 to R12,500" option526="526;.;R12,500 plus" option531="531;.;R3,000 to R4,000" option530="530;.;R4,000 to R5,000" option529="529;.;R5,000 to R7,500" option528="528;.;R7,500 to R10,000" /> <select id="525" key="Fitment" option520="520;.;ASAP" option525="525;.;Not within the next 3 months" option523="523;.;Within the next 2 months" option521="521;.;Within the next 2 weeks" option524="524;.;Within the next 3 months" option522="522;.;Within the next month" /> <select id="286" key="Requirement" option289="289;.;New - Colour-coded" option288="288;.;New - White" option287="287;.;Pre-owned - Colour-coded" option286="286;.;Pre-owned - White" /> <select id="393" key="budget" option397="397;.;R10,000 to R12,500" option398="398;.;R12,500 plus" option393="393;.;R3,000 to R4,000" option394="394;.;R4,000 to R5,000" option395="395;.;R5,000 to R7,500" option396="396;.;R7,500 to R10,000" /> <select id="1" key="canopy_req" option2="2;.;new_colour_coded" option1="1;.;new_white" option12="12;.;pre-owned_colour_coded" option11="11;.;pre-owned_white" /> <select id="519" key="fitment" option514="514;.;ASAP" option519="519;.;not_within_3_months" option517="517;.;within_2_months" option515="515;.;within_2_weeks" option518="518;.;within_3_months" option516="516;.;within_month" /> </service> </services> <sql></sql></root> easier to keep track of while parsing
  22. i've redone the xml last night - i see the categories are a four dimentional array - and the services a 3 dimentional array, here is a view of the data retrieved into a multidimentional array (there will eventually be more than one category): A Category arrayArray { 1, 1, "Category A", 20, Array { 531, "Budget", "disabled" }, Array { 525, "Fitment", "disabled" }, Array { 286, "Requirement", "disabled" }, Array { 393, "budget", "disabled", Array { 397, "R10,000 to R12,500", 1 } }, Array { 1, "canopy_req", "disabled", Array { 1, "new_white", 1 } }, Array { 519, "fitment", "disabled" }}Services ArrayArray { 1, "Bakkie Canopy", "selected" Array { 531, "Budget", "disabled", Array { 527, "R10,000 to R12,500" }, Array { 526, "R12,500 plus" }, Array { 531, "R3,000 to R4,000" }, Array { 530, "R4,000 to R5,000" }, Array { 529, "R5,000 to R7,500" }, Array { 528, "R7,500 to R10,000" } }, Array { 525, "Fitment", "disabled", Array { 520, "ASAP" }, Array { 525, "Not within the next 3 months" }, Array { 523, "Within the next 2 months" }, Array { 521, "Within the next 2 weeks" }, Array { 524, "Within the next 3 months" }, Array { 522, "Within the next month" } }, Array { 286, "Requirement", "disabled",, Array { 289, "New - Colour-coded" }, Array { 288, "New - White" }, Array { 287, "Pre-owned - Colour-coded" }, Array { 286, "Pre-owned - White" } }, Array { 393, "budget", "disabled",, Array { 527, "R10,000 to R12,500" }, Array { 526, "R12,500 plus" }, Array { 531, "R3,000 to R4,000" }, Array { 530, "R4,000 to R5,000" }, Array { 529, "R7,500 to R10,000" } }, Array { 1, "canopy_req", "disabled", Array { 2, "new_colour_coded" }, Array { 1, "new_white" }, Array { 12, "pre-owned_colour_coded" }, Array { 11, "pre-owned_white" } }, Array { 519, "fitment", "disabled", Array { 514, "ASAP" }, Array { 519, "not_within_3_months" }, Array { 517, "within_2_months" }, Array { 515, "within_2_weeks" }, Array { 518, "within_3_months" }, Array { 512, "within_month" } }} these are the functions that collapse and expand this multidimentional array. i am thinking that perhaps the levels need to be added as parameter to specify how deep to parse. i'm as yet still on this one. function collapse(arr) { for (var i = 0; i < arr.length; i++) { if (arr[i] instanceof Array) { for (var j = 0; j < arr[i].length; j++) { if (arr[i][j] instanceof Array) { arr[i][j] = arr[i][j].join(";;"); } } arr[i] = arr[i].join(";;;"); } } return arr.join(";;;;");; }function expand(str) { var arr = str.split(";;;;"); for (var i = 0; i < arr.length; i++) { if (arr[i].indexOf(";;;")) { arr[i] = arr[i].split(";;;"); for (var j = 0; j < arr[i].length; j++) { if (arr[i][j].indexOf(";;")) { arr[i][j] = arr[i][j].split(";;"); } } } } return arr;}
  23. well unfortunately i cannot store them as comma delimited, because some attributes (especially the budgets) have comma's in them. also, i need to restore the multidimentional array at a later stage to parse and insert into the form elements...
×
×
  • Create New...