The usage of \0 is most likely what is causing it. I recall issues like this in other languages.. not sure about mysql or php. 0 is a NULL character and used to terminate strings. If encountered, the function retrieving the data might be thinking the string has ended.
was the data serialized with php? if so, why aren't there semicolons? if you are converting them to NULLs, why? lemmie know.. --------------------------------- Charlie Jacquez PHP, XHTML, CSS, JavaScript, and Video Editing View My Portfolio: http://heresmy.net/?a=portfolio On Wed, Nov 12, 2008 at 2:51 AM, PI <[EMAIL PROTECTED]> wrote: > > Hi Guys, > > I need some assistance with the following scenario please. I have some > serialized data that I would like to store in a MySQL database. When > viewed, the serialized data looks like this: > > O:4:\"cart\":4:{s:15:\"\0cart\0c_cart_id\";N;s:18:\"\0cart > \0c_cart_owner\";s:5:\"owner\";s:22:\"\0cart\0c_cart_date_time\";N;s: > 20:\"\0cart\0c_arr_contents\";a:1:{i:0;O:9:\"cart_item\":5:{s: > 25:\"\0cart_item\0c_cart_item_id\";s:3:\"162\";s:27:\"\0cart_item > \0c_cart_item_name\";s:10:\"30BWL15481\";s:34:\"\0cart_item > \0c_cart_item_description\";s:23:\"BOWL,MINIDOT,PRISM,POLY\";s: > 31:\"\0cart_item\0c_cart_item_quantity\";i:1;s:20:\"\0cart_item > \0c_cart_id\";N;}}} > > The problem is that I have not been able to successfully persist this > data in the database. The Schema I am currently using for the table > is: > +--------------+--------------+------+-----+---------+---------------- > + > | Field | Type | Null | Key | Default | Extra > | > +--------------+--------------+------+-----+---------+---------------- > + > | order_id | int(10) | NO | PRI | NULL | auto_increment > | > | order_number | varchar(255) | YES | | NULL | > | > | user_id | varchar(255) | YES | | NULL | > | > | product_data | longtext | YES | | NULL | > | > | session_data | varchar(255) | YES | | NULL | > | > | date | varchar(255) | YES | | NULL | > | > +--------------+--------------+ > > > > When I attempt to insert this data in the table using the following > query statement: > > SQL query is is: INSERT INTO spares_order (order_number, user_id, > product_data, session_data, date) VALUES ('tlx-18954XM', > '[EMAIL PROTECTED]', 'O:4:\"cart\":4:{s:15:\"\0cart\0c_cart_id\";N;s: > 18:\"\0cart\0c_cart_owner\";s:5:\"owner\";s:22:\"\0cart > \0c_cart_date_time\";N;s:20:\"\0cart\0c_arr_contents\";a:1:{i:0;O: > 9:\"cart_item\":5:{s:25:\"\0cart_item\0c_cart_item_id\";s:3:\"162\";s: > 27:\"\0cart_item\0c_cart_item_name\";s:10:\"30BWL15481\";s: > 34:\"\0cart_item\0c_cart_item_description\";s: > 23:\"BOWL,MINIDOT,PRISM,POLY\";s:31:\"\0cart_item\0c_cart_item_quantity > \";i:1;s:20:\"\0cart_item\0c_cart_id\";N;}}}', > '0cae0dd4494d178a04244be03fff68cd', 'Wednesday 12th of November 2008 > 09:58:29 AM') > > I have no error messages but the table column product_data which > ought to hold the serialized data holds only part of the complete > string as shown: > > +----------------------+ > | product_data | > +----------------------+ > | O:4:"cart":4:{s:15:" | > +----------------------+ > > > I understand this might have to do with certain characters within > that serialized data that needs to be escaped. I have attempted a > number of escape options but none seems to work for me. I would > appreciate some assistance with this please. Thanks a lot. > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "PHP & MySQL" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/phpmysql?hl=en -~----------~----~----~----~------~----~------~--~---
