Jarin Posted May 10, 2006 Share Posted May 10, 2006 I'm having a very strange problem that I've never encountered before. It's rather simple actually, but I can't find any reason why it would do this.So, I have a serialized array like this: a:1:{s:5:"night";s:1:"1";} which is stored in the variable $world['flags']. If I were to echo that variable, it prints out exactly as it should, a:1:{s:5:"night";s:1:"1";}However, if I assign a variable like this:$wflag = $world['flags'];Then $wflag will return a NULL value. It doesn't store the information at all. Below is the entire portion of the script in question. And yes, 'flags' is a valid field in the result. Everything else in the query works as it should. $worlds = $DB_site->query("SELECT * FROM vb3_heroadmin WHERE world='$worldid'"); $world = mysql_fetch_array($worlds); $worldn = $world['name']; $optionx = $world['xpmult']; $optiong = $world['goldmult']; $optioni = $world['itemrarity']; $optiona = $world['aprarity']; $wflag = $world['flags'];Thanks for any help you might offer. Quote Link to comment https://forums.phpfreaks.com/topic/9465-strange-problem/ Share on other sites More sharing options...
ober Posted May 10, 2006 Share Posted May 10, 2006 I'm going to guess that you need to unserialize it before transferring it to a PHP variable. Quote Link to comment https://forums.phpfreaks.com/topic/9465-strange-problem/#findComment-34910 Share on other sites More sharing options...
kenrbnsn Posted May 10, 2006 Share Posted May 10, 2006 Put some debuging code in:[code]<?php$worlds = $DB_site->query("SELECT * FROM vb3_heroadmin WHERE world='$worldid'");$world = mysql_fetch_assoc($worlds); // changed from mysql_fetch_array to mysql_fetch_assocecho '<pre>' . print_r($world,true) . '</pre>'; // debug line -- check that you're getting what you think you're getting$worldn = $world['name'];$optionx = $world['xpmult'];$optiong = $world['goldmult'];$optioni = $world['itemrarity'];$optiona = $world['aprarity'];$wflag = $world['flags'];echo '$wflag = ' . $wflag . '<br>'; // another debug line.?>[/code]You should be able to move the value to any variable without unserializing it.Ken Quote Link to comment https://forums.phpfreaks.com/topic/9465-strange-problem/#findComment-34921 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.