ID: 19945 Comment by: skold at habber dot net Reported By: gaopeng at eazier dot com Status: No Feedback Bug Type: Arrays related Operating System: FreeBSD 4.2 PHP Version: 4.2.2 New Comment:
Ok, I narrowed it down. mysql_query does something similar to stripslashes on text, which is where the \ in Test\'s was going. Obviously it doesn't alter the serialized array to show 6 bytes instead of 7. Just do mysql_real_escape_string() on the serialized array before throwing it into mysql_query() and it should be fine! Previous Comments: ------------------------------------------------------------------------ [2004-02-10 07:47:25] skold at habber dot net I've run into this problem as well. So far I've had the same problem on 4.3.2, 4.3.4, 4.3.5RC2. The latest snapshot (as of Feb 10) won't compile for me. The problem, like gaopeng said, is with quotes and such. serialize() doesn't store the proper length and it won't unserialize properly. For example: a:1:{i:1;s:7:"Test's";} It says it's 7 bytes long, when it's only 6. If I addslashes() to it, it does this: a:1:{i:1;s:9:"Test\'s";} It's now 7 but it says its 9. Are there any workarounds for this? ------------------------------------------------------------------------ [2002-11-04 01:00:06] php-bugs at lists dot php dot net No feedback was provided for this bug for over 2 weeks, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2002-10-17 00:42:34] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php4-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-latest.zip ------------------------------------------------------------------------ [2002-10-17 00:04:29] gaopeng at eazier dot com when serialize a array which contains special characters such as "'", """, "\", php4 cannot unserialize it correct, i think the problem is the length of string when do unserialize. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19945&edit=1