PHP unserialize() not working while trying to store facebook user data
I am trying to store facebook user's data array in mysql. I have used serialize for the conversion of array. When I try to retrieve data, I get absolute blank page. No errors, no output. I have given my code with example below. Please help me to find error.
$arrayString='a:18:{s:2:"id";s:10:"7234123543";s:4:"name";s:18:"John Mc Carthy";s:10:"first_name";s:7:"John";s:11:"middle_name";s:5:"Mc";s:9:"last_name";s:4:"Carthy";s:4:"link";s:35:"http://www.facebook.com/johnmc";s:8:"username";s:11:"johnmc";s:8:"hometown";a:2:{s:2:"id";s:15:"112334563280811";s:4:"name";s:7:"Some city";}s:8:"location";a:2:{s:2:"id";s:15:"112312348780092";s:4:"name";s:16:"Some city, country";}s:6:"quotes";s:234:""All children are artists. The problem is how to remain an artist once you grow up."
- Pablo Picasso
"Boundaries are meant to be broken"
- Malik raza
"Make things as simple as possible but no simpler."
- Albert Einstein";s:20:"inspirational_people";a:6:{i:0;a:2:{s:2:"id";s:15:"109233712349424";s:4:"name";s:10:"Bill Gates";}i:1;a:2:{s:2:"id";s:15:"108103675884224";s:4:"name";s:20:"A. P. J. Abdul Kalam";}i:2;a:2:{s:2:"id";s:15:"104389809597530";s:4:"name";s:13:"Chris Gardner";}i:3;a:2:{s:2:"id";s:11:"11777366210";s:4:"name";s:12:"Paulo Coelho";}i:4;a:2:{s:2:"id";s:11:"68310606562";s:4:"name";s:15:"Mark Zuckerberg";}i:5;a:2:{s:2:"id";s:15:"113529011990795";s:4:"name";s:10:"Steve Jobs";}}s:9:"education";a:2:{i:0;a:4:{s:6:"school";a:2:{s:2:"id";s:15:"110123445652281";s:4:"name";s:5:"college";}s:4:"year";a:2:{s:2:"id";s:15:"144044823450606";s:4:"name";s:4:"2011";}s:13:"concentration";a:1:{i:0;a:2:{s:2:"id";s:15:"192578844099494";s:4:"name";s:16:"Computer Science";}}s:4:"type";s:7:"College";}i:1;a:2:{s:6:"school";a:2:{s:2:"id";s:15:"103122365394699";s:4:"name";s:22:"My School";}s:4:"type";s:11:"High School";}}s:6:"gender";s:4:"male";s:5:"email";s:19:"myemail@gmail.com";s:8:"timezone";d:15.5;s:6:"locale";s:5:"en_US";s:8:"verified";b:1;s:12:"updated_time";s:24:"2011-04-09T21:51:29+0000";}';
$array=unserialize($arrayString);
//echo $array[0];
print_r($array);开发者_StackOverflow社区
Most likely your serialized data is malformed / you've forgotten to escape characters that need escaping. To get php to give you some verbose error report on this turn on error reporting and display errors:
ini_set("error_reporting", E_ALL);
ini_set("display_errors", 1);
"Notice" isn't normally an important enough error message to get displayed, but in this case it will help you debug the problem with your serialization:
Notice: unserialize(): Error at offset 68 of 1720 bytes in file.php on line 7
精彩评论