Hi,
i need help on following:
<?php
$connect = mysql_connect("sql113.0fees.net", "fees0_4998969");
mysql_select_db ("fees0_4998969_gielel");
$select = "SELECT `user_data` FROM `ci_sessions`";
$i = mysql_query($select);
$h = mysql_fetch_row($i);
print_r($h); // - this returns serialized array
// if i write: $v = unserialize($h); print_r($v);
// it would return nothing
?>
what i'm doing wrong?
problem with unserializing data
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: problem with unserializing data
mysql_fetch_row() does not return a serialized array, it returns an array of the columns and data from the query result. To access the the returned column you would use $h[0]. You might like mysql_fetch_assoc() better as you can then use $h['user_data']. If you mean that the contents of `user_data` is serailized, then you would use:
Code: Select all
$v = unserialize($h[0]);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: problem with unserializing data
thanks for answer!
now i use:
$h = mysql_fetch_assoc($i);
$v = unserialize($h['user_data']);
print_r($v);
but again it returns nothing, though:
$d = ($h['user_data']);
print_r($d); // returns serialized object
now i use:
$h = mysql_fetch_assoc($i);
$v = unserialize($h['user_data']);
print_r($v);
but again it returns nothing, though:
$d = ($h['user_data']);
print_r($d); // returns serialized object
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: problem with unserializing data
Are you sure it's an object? If so then you need to include the class that the object is instantiated from before you unserialize it.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: problem with unserializing data
Also, now that I re-read your first post, is it possible that this data is being written to the DB by the session handler? If so the serialized data is a different format from the serialze() function. There is no internal function that you can use to unserialize this that I know of. You'll either have to search for a hack or serialize it yourself before inserting it.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: problem with unserializing data
Hello alega,
It is really not good to put your mysql user information on to the forums. consider changing it to some random values.
Thank You
dude
It is really not good to put your mysql user information on to the forums. consider changing it to some random values.
Thank You
dude