Mysql Insert PHP colons, semi colons and double quotes -


i writing custom script insert data wordpress database. database contains address section , data in field has various colons, semi colons , double quotes. having hard time trying write php mysql insert statement. getting lot of syntax errors.

the field looks like:

a:9:{s:8:"address1";s:7:"street1";s:8:"address2";s:7:"street2";s:4:"city";s:9:"london";s:5:"state";s:5:"bucks";s:11:"postal_code";s:8:"mk49 8uy";s:7:"country";s:2:"gb";s:13:"logo_image_id";s:1:"0";s:5:"notes";s:0:"";s:12:"instructions";s:0:"";} 

can offer guidance on how escape such large number of characters

as roberto suggests - if attempting insert pre formatted serialized array database (and has error) it's not going work. if collecting data individually , building simpler way go first construct array, convert format can stored in database (serialised arrays). example:

$address = array(  'address1'    => 'street1',  'address2'    => 'street2',  'city'        => 'london',  'state'       => 'bucks',  'postal_code' => 'mk49 8uy',  'country'     => 'gb', );  $formattedaddress = serialize($address); // returns // a:6:{s:8:"address1";s:7:"street1";s:8:"address2";s:7:"street2";s:4:"city";s:6:"london";s:5:"state";s:5:"bucks";s:11:"postal_code";s:8:"mk49 8uy";s:7:"country";s:2:"gb";} 

you can reference $address within insert statement correctly formatted serialized array.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -