PDA

View Full Version : unserialize not working correctly


TomasDR
11 Feb 2007, 22:37
I am trying to use a hack that is no longer supported and the original coder isn't replying even on his own board. I am hoping someone can assist me since I am very confused about what is wrong.

I am using FC4 with updated RPMs, so PHP=5.0.4 & SQL=4.1.20, I also use MYSQLi to connect to the database.

The original code is:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I know $cdfield is working and returning the proper field#.

So I made this test code to figure out what is wrong:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I receive:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



My raw data in the SQL table looks like this:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Any help would be greatly appreciated.

Analogpoint
12 Feb 2007, 03:20
Did you try doing an unserialize on the serialized data before other manipulations such as the str_replace?

EDIT:
Also, mysql_query returns a MySQL "resource", you should pass it to one of the functions such as mysql_fetch_assoc to return a php array of the data.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

SirAdrian
12 Feb 2007, 03:23
Bingo.

Remember that a when you serialize something, PHP records the lengths of all the strings, arrays, etc. Changing things like " to " would muck this up, resulting in an usable data.