Re: 4.3.7 array serialize problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sunday 26 December 2004 16:41, pf@xxxxxxxxxxxxxxxxxxxxxxxx wrote:

> Have PHP 4.3.7, magic_quotes_gpc = On
> Have a multidimensional array made from values from a POST form.
> It addslashes() every field of the form as expected, like (') => (\'),
> etc.
> When I searialize the array to put it into a mysql db it seems to fail
> to describe the string lenght of values with the (') character, like
> this:
> $arr['PestName']="a'cqua", it results the following in the serialized
> string stored in the db:
> a:1:{i:1;a:5:{s:8:"PestName";s:7:"a'cqua"....
> note that "a'cqua" is not 7 chars lenght, but 6.
> The problem is when I try to recover the array with unserialize(), it
> fails, returning false. It is obvious that php is counting the (\)
> character when serializing the string, but it stores it without it in
> the db, so when it tries to recover the array, it fails.
> Is this a known bug? Are there any workarounds you know?

addslashes() is supposed to be applied to the value of the column (field). In 
this case the value is the finished serialized array. In other words 
serialize() then addslashes(). Also you ought to be using 
mysql_real_escape_string() rather than addslashes().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Lonesome?

Like a change?
Like a new job?
Like excitement?
Like to meet new and interesting people?

JUST SCREW-UP ONE MORE TIME!!!!!!!
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux