nuglobe Posted October 17, 2006 Share Posted October 17, 2006 Alright so this is the entry that was stored in the database:a:1:{s:6:"Andrew";s:17:"[email protected]";}Here is the function that serializes it. Note - $_SESSION['stateEmails'] is passed through as the request array.[code]function submit_request($uID, $requestArray){ $players = serialize($requestArray); $status = 1; $query = "INSERT INTO requests (uID, playersID, status) VALUES ('$uID', '$players', '$status')"; mysql_query ($query) or die ('Could not submit request!.'); }[/code]Here is the code that creates the array.[code]$_SESSION['stateEmails'][$rowprof['uFName']] = $rowprof['uEmail'];[/code]Its in a loop, so there cool be more to it then the one posted at the top.And finally here is the function I am trying to use to pull from the database, unserialize and display.[code]function get_open_requests($uID){ $status = 1; $query = "SELECT playersID FROM requests WHERE uID = $uID AND status = $status"; $pull = mysql_query($query); $players = unserialize($pull); print_r($players);}[/code]What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/24170-unserialize-returning-false/ Share on other sites More sharing options...
manichean Posted October 17, 2006 Share Posted October 17, 2006 Hello the problem lies in this section of your codeYour code:[quote]function get_open_requests($uID){ $status = 1; $query = "SELECT playersID FROM requests WHERE uID = $uID AND status = $status"; $pull = mysql_query($query); $players = unserialize($pull); print_r($players);}[/quote]Completed fixed code:[quote]function get_open_requests($uID){ $status = 1; $query = "SELECT playersID FROM requests WHERE uID = '$uID' AND status = '$status'"; $pull = mysql_query($query); $row = mysql_fetch_assoc($pull); $players = unserialize($row['playersID']); print_r($players);}[/quote]always remember a mysql_query stored into a variable storeds its RESOURCE ID # not the values obtained from the table. And always encapsulate your variables in a select or insert statment with ' ' single quotesHope this helps yacheers Link to comment https://forums.phpfreaks.com/topic/24170-unserialize-returning-false/#findComment-109871 Share on other sites More sharing options...
nuglobe Posted October 17, 2006 Author Share Posted October 17, 2006 Thanks! :D Link to comment https://forums.phpfreaks.com/topic/24170-unserialize-returning-false/#findComment-110148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.