I already asked this before and now I know how to serialize it. But now the problem is I am having this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''address1t', 'address2t', 'cityt', 'provincet', 'postalCODEt', 'contactNOt', 'em' at line 1
This is my associative array:
Array ( [0] => Array ( [recNAME] => NAME1 [company] => [address1] => ADDRESS1 [address2] => [city] => CITY1 [province] => PROVINCE1 [postalCODE] => 0 [contactNO] => 926XXXXX [email] => [email protected] [commodity] => COMMODITY1 [type] => [weight] => 0 [length] => 0 [width] => 0 [height] => 0 [decVAL] => 0 [specINSTRUC] => [shipREF] => REF1 [payMETHOD] => CashOnDelivery [packNO] => 200XXXX-XXX [trackNO] => 200XXXX-XXX ) [1] => Array ( [recNAME] => NAME2 [company] => [address1] => ADDRESS2 [address2] => [city] => CITY2 [province] => PROVINCE2 [postalCODE] => 0 [contactNO] => 905XXXXXX [email] => [email protected] [commodity] => COMMODITY2 [type] => [weight] => 0 [length] => 0 [width] => 0 [height] => 0 [decVAL] => 361 [specINSTRUC] => I'm in the above given address from M-F, 11AM-6PM, call or text me for confirmation [shipREF] => 200XXXXX [payMETHOD] => CashOnDelivery [packNO] => 200XXXX-XXX [trackNO] => 200XXXX-XXX ) )
And the serialized array looks like this:
a:4:{i:0;a:21:{s:7:"recNAME";s:18:" NAME1";s:7:"company";s:0:"";s:8:"address1";s:57:"ADDRESS1";s:8:"address2";s:0:"";s:4:"city";s:8:"CITY1";s:8:"province";s:8:"PROVINCE1";s:10:"postalCODE";s:1:"0";s:9:"contactNO";s:10:"9XXXXXXXX";s:5:"email";s:21:"[email protected]";s:9:"commodity";s:13:"COMMODITY1";s:4:"type";s:0:"";s:6:"weight";s:1:"0";s:6:"length";s:1:"0";s:5:"width";s:1:"0";s:6:"height";s:1:"0";s:6:"decVAL";s:2:"99";s:11:"specINSTRUC";s:0:"";s:7:"shipREF";s:9:"200XXXX";s:9:"payMETHOD";s:14:"CashOnDelivery";s:6:"packNO";s:14:"200XXXX-XXX";s:7:"trackNO";s:14:"200XXXX-XXX";}i:1;a:21:{s:7:"recNAME";s:32:" NAME2";s:7:"company";s:0:"";s:8:"address1";s:52:"ADDRESS1";s:8:"address2";s:0:"";s:4:"city";s:6:"CITY2";s:8:"province";s:12:"PROVINCE2";s:10:"postalCODE";s:1:"0";s:9:"contactNO";s:10:"9XXXXXX";s:5:"email";s:23:"[email protected]";s:9:"commodity";s:7:"Spyder ";s:4:"type";s:0:"";s:6:"weight";s:1:"0";s:6:"length";s:1:"0";s:5:"width";s:1:"0";s:6:"height";s:1:"0";s:6:"decVAL";s:3:"361";s:11:"specINSTRUC";s:83:"I'm in the above given address from M-F, 11AM-6PM, call or text me for confirmation";s:7:"shipREF";s:9:"200XXXXX";s:9:"payMETHOD";s:14:"CashOnDelivery";s:6:"packNO";s:14:"200XXXX-XXX";s:7:"trackNO";s:14:"200XXXX-XXX";}}
And this is my code on serializing it:
$newstring = serialize($array);
@mysql_query("INSERT INTO `temp` (`recNAMEt`, `companyt`, 'address1t', 'address2t', 'cityt', 'provincet', 'postalCODEt', 'contactNOt', 'emailt', 'commodityt', 'typet', 'weightt', 'lengtht', 'widtht', 'heightt', 'decVALt', 'specINSTRUCt', 'shipREFt', 'payMETHODt', 'packNOt', 'trackNOt' ) VALUES('', $newstring)") or die('Error: ' . mysql_error());
This is my first time to serialize and I am still getting a handle on things. I still don't know what went wrong because this code worked for a normal array. I tried doing this:
VALUES('', '', $newstring)")
still no luck. The recNAMEt, companyt, etc are column names in my table. Please help. Thanks and regards.