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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.