Jump to content

Strange problem..


Jarin

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/9465-strange-problem/
Share on other sites

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_assoc
echo '<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
Link to comment
https://forums.phpfreaks.com/topic/9465-strange-problem/#findComment-34921
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.