Greywacke Posted March 25, 2010 Share Posted March 25, 2010 hi there,many of you have told me to use multidimentional arrays rather than strings which are later split... i would like to know why this is so, i suspect it has something to do with the problem i am having at the moment. in the first stages of this handler, it worked perfectly - but now it's dropping the last two items of the array.the array is created by going through requirements and if meeting them, it is included like follows: array_push( $GLOBALS[($status==2)?"mailaddp":"mailadds"], $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"].";;;". $row["text_GoogleMapsURL"].";;;". $row["text_VTigerData"]); then later in the code, when testing this array ($mailadds and $mailaddp, where they are used) it outputs the split strings as follows: getsuppliers($service,0); (returns $mailadds array by [b]$recipient = split(";;;",$add);[/b]): $mailadds[0] $recipient[0]=Riette Bradford $recipient[1]=Test Supplier Three $recipient[2]=pierre@greywacke.co.za $recipient[3]=9880 $recipient[4]=27729154799 $recipient[5]=Supreme Industrial Park, Unit F 25, Cnr. Heidelberg Road & Southern Klipriviersberg Road, Steeledale, Johannesburg $recipient[6]=20 $recipient[7]= $recipient[8]=getsuppliers($service,2); (returns $mailaddp array by [b]$recipient = split(";;;",$add);[/b]): $mailaddp[0] $recipient[0]=Riëtte Bradford $recipient[1]=Test Supplier One $recipient[2]=pierre@greywacke.co.za $recipient[3]=9960, $recipient[4]=27729154799 $recipient[5]=Supreme Industrial Park, Unit F 25, Cnr. Heidelberg Road & Southern Klipriviersberg Road, Steeledale, Johannesburg $recipient[6]=18 $recipient[7]= $recipient[8]= $mailaddp[1] $recipient[0]=Pierre du Toit $recipient[1]=Test Supplier Two $recipient[2]=pierre@greywacke.co.za $recipient[3]=10000 $recipient[4]=27729154799 $recipient[5]=880 13th Avenue, Wonderboom South, Pretoria, 0084 $recipient[6]=19 $recipient[7]= $recipient[8]= notice the last two elements of the split arrays are dropped. could this be because of a stack overflow or something? i am not receiving any errors, yet there should be? the database field names are correct (text_GoogleMapsURL and text_VTigerData). could anyone please give me some clarity! i can't seem to find anything on the web with regard to multidimentional arrays vs split strings. Link to comment Share on other sites More sharing options...
Greywacke Posted March 25, 2010 Author Share Posted March 25, 2010 this string created, does not insert those two fields, here is the entire function for retrieving suppliers and their info: function getsuppliers($sid,$status) { $GLOBALS[($status==2)?"mailaddp":"mailadds"] = array(); // try check for all attributeid's within loop for supplier foreach ($GLOBALS["attribids"] as $aid) { $sql1 = "SELECT text_ContactFirstName,text_ContactSurname, text_SupplierName,`text_ContactE-mail`, bigint_CurrentBalance, bigint_ContactTel, text_SupplierAddress, 5_suppliers.bigint_SupplierID, text_GoogleMapsURL, text_VTigerData FROM 9_supplierattributes JOIN (5_suppliers) ON ( 9_supplierattributes.bigint_SupplierID = 5_suppliers.bigint_SupplierID ) WHERE smallint_SupplierStatus = ".$status." AND bigint_ServiceID = ".$sid." AND bigint_AttributeID = ".$aid." AND bigint_RegionID = ".$GLOBALS["region"].";\n"; $GLOBALS["sql"] .= $sql1; $result1 = mysql_query($sql1); $err = mysql_error(); $GLOBALS["sql"] .= strtoupper($err)."\n"; if ($result1) { while ($row1 = mysql_fetch_array($result1)) { if (arrTrue(hasAttribs($row1["bigint_SupplierID"])) && !in_array(";;;".$row1["bigint_SupplierID"].";;;", $GLOBALS[($status==2)?"mailaddp":"mailadds"]) && $row1["bigint_CurrentBalance"] >= $GLOBALS["servicecost"]) { array_push($GLOBALS[($status==2)?"mailaddp":"mailadds"], $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"].";;;". $row["text_GoogleMapsURL"].";;;". $row["text_VTigerData"]); } } } mysql_free_result($result1); }} ah lol i noticed the last two items did not have the correct variable, just $row as opposed to $row1... issue seems to be resolved Link to comment Share on other sites More sharing options...
boen_robot Posted March 25, 2010 Share Posted March 25, 2010 For future's sake, may I suggest you at least try to create some reduced samples that show the problem? There are many variables in your scripts... too many for most people to keep up with. Link to comment Share on other sites More sharing options...
Greywacke Posted March 25, 2010 Author Share Posted March 25, 2010 well, only half of the problem was resolved... an issue still remains.why is it that elements 0 - 8 exist after being split, but certain elements are dropped by the time they are used?only 0-3 remains in the array...this is what remains in the two $mailaddp elements: $recipient[0]=Riette Bradford, $recipient[1]=Test Supplier One, $recipient[2]=pierre@greywacke.co.za, $recipient[3]=9960$recipient[0]=Pierre du Toit, $recipient[1]=Test Supplier Two, $recipient[2]=pierre@greywacke.co.za, $recipient[3]=10000 Link to comment Share on other sites More sharing options...
boen_robot Posted March 25, 2010 Share Posted March 25, 2010 You might want to do some var_dump()-ing around, see what you can find. Link to comment Share on other sites More sharing options...
Greywacke Posted March 25, 2010 Author Share Posted March 25, 2010 these are the arrays ealier directly after being split earlier in the page: $recipient[0]=Riette Bradford, $recipient[1]=Test Supplier One, $recipient[2]=pierre@greywacke.co.za, $recipient[3]=9960, $recipient[4]=27729154799, $recipient[5]=Supreme Industrial Park, Unit F 25, Cnr. Heidelberg Road & Southern Klipriviersberg Road, Steeledale, Johannesburg, $recipient[6]=18, $recipient[7]=http://maps.google.co.za/maps/ms?msa=0&msid=102191045390808171562.0004803ec16dc5f3dd9ac&hl=en&ie=UTF8&ll=-26.242607,28.101879&spn=0.008834,0.01649&z=17, $recipient[8]=http://www.canopyxchange.za.net/andycab;roadrunner_jhb;XrCi9yRcNicVzBxjPAUSE$recipient[0]=Pierre du Toit, $recipient[1]=Test Supplier Two, $recipient[2]=pierre@greywacke.co.za, $recipient[3]=10000, $recipient[4]=27729154799, $recipient[5]=880 13th Avenue, Wonderboom South, Pretoria, 0084, $recipient[6]=19, $recipient[7]=, $recipient[8]= why are elements 4-8 dropped without any error being displayed? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 25, 2010 Share Posted March 25, 2010 The original problem was an error (undefined variables), if you didn't see an error message then error reporting is set too low. You can use this to display all errors:ini_set('display_errors', 1);error_reporting(E_ALL);That might give some more information about where the problem is. why are elements 4-8 dropped without any error being displayed?There's something in the code between when you first create the arrays and when they get truncated which is doing that, that wouldn't happen automatically. Link to comment Share on other sites More sharing options...
Greywacke Posted March 25, 2010 Author Share Posted March 25, 2010 ah forgot to reply... my apologies, issue has been resolved. the array $recipients was redefined between where it was created and where it was used. thanks justsomeguy, will use that if i need it (but i believe my apache development server is set to E_ALL by default...) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.