Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1062695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:40:01+00:00 2026-05-16T18:40:01+00:00

We just switched our website over to a new server. There is a part

  • 0

We just switched our website over to a new server. There is a part of my PHP software that pulls out a serialized data value from the MySQL table, and puts it into a variable, and then it’s supposed to unserialize().

I never had this issue on any other servers (and this exact code is used on many different servers..), but I’m getting an issue where the value fails to unserialize – it returns false (blank).

HOWEVER, if I copy the exact value, put it into another $var, and then unserialize($var) it, it works perfectly fine into an array… they are the exact same values. One works, the other doesn’t.

Check out the following link to visualize what I mean..

http://paulmasoumi.com/admin/test.php

And the PHP code on this page is:

<?
include 'start.php';

$var = 'a:8:{i:0;s:0:"";i:1;s:11:"New Listing";i:2;s:11:"Just Listed";i:3;s:9:"New Price";i:4;s:17:"Exclusive Listing";i:5;s:12:"Just Reduced";i:6;s:31:"Great Price!;Showroom Condition";i:7;s:42:"Featured In;Dream Homes of Canada Magazine";}';


echo 'Echoing $var:<br />';
echo $var;
echo '<br />';


echo 'Echoing $settings[\'remarksdisplay\'] retrieved from mysql database field:<br />';
echo $settings['remarksdisplay'];
echo '<br />';

echo '<br />';

echo 'When you run print_r(unserialize($var)):<br />';
print_r(unserialize($var));
echo '<br />';

echo 'When you run print_r(unserialize($settings[\'remarksdisplay\'])):<br />';
print_r(unserialize($settings['remarksdisplay']));

echo '<br />';
echo '<br />';

echo 'When you run IF statement to see if $settings[\'remarksdisplay\']==$var:<br />';
if($settings['remarksdisplay']==$var) {echo "EQUAL";} else {echo 'not equal';}
?>

I’ve also checked the server settings regarding the serialize() and unserialize() functions…

Check out these two settings:
http://www.paulmasoumi.com/admin/phpinfo.php
http://demo.brixwork.com/admin/phpinfo.php

Settings involving serialization of strings, magic quotes etc. are all identical.

What am I missing???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:40:01+00:00Added an answer on May 16, 2026 at 6:40 pm

    The strings are not identical. Viewing the source of your page the one coming out of the database has a linebreak:

    a:8:{i:0;s:0:"";i:1;s:11:"New Listing";i:2;s:11:"Just Listed";i:3;s:9:"New Price";i:4;s:17:"Exclusive Listing";i:5;s:12:"Just Reduced";i:6;s:31:"Great 
    Price!;Showroom Condition";i:7;s:42:"Featured In;Dream Homes of Canada Magazine";
    

    As you can see after Great. But, it should handle the new line characters just fine. When I copied the database serialized string and tried to unserialize it I received a:

    PHP Notice: unserialize(): Error at offset 176 of 234 bytes in php shell code on line 1

    Which means something funky is happening, not sure what. I am going to keep digging, but just posting what I found out. If you want a true test, however, add a newline after Great.

    UPDATE

    <?php
    $var = 'a:8:{i:0;s:0:"";i:1;s:11:"New Listing";i:2;s:11:"Just Listed";i:3;s:9:"New Price";i:4;s:17:"Exclusive Listing";i:5;s:12:"Just Reduced";i:6;s:31:"Great' . "\n" .  
    'Price!;Showroom Condition";i:7;s:42:"Featured In;Dream Homes of Canada Magazine";}';
    
    $settings['remarksdisplay'] = 'a:8:{i:0;s:0:"";i:1;s:11:"New Listing";i:2;s:11:"Just Listed";i:3;s:9:"New Price";i:4;s:17:"Exclusive Listing";i:5;s:12:"Just Reduced";i:6;s:31:"Great
    Price!;Showroom Condition";i:7;s:42:"Featured In;Dream Homes of Canada Magazine";}';
    
    echo 'Echoing $var:' . PHP_EOL;
    echo $var;
    echo "\n\n";
    
    
    echo 'Echoing $settings[\'remarksdisplay\'] retrieved from mysql database field:' . PHP_EOL;
    echo $settings['remarksdisplay'];
    
    echo "\n\n";
    
    echo 'When you run print_r(unserialize($var)):' . PHP_EOL;
    print_r(unserialize($var));
    echo "\n";
    
    echo 'When you run print_r(unserialize($settings[\'remarksdisplay\'])):' . PHP_EOL;
    print_r(unserialize($settings['remarksdisplay']));
    
    echo "\n\n";
    
    echo 'When you run IF statement to see if $settings[\'remarksdisplay\']==$var:' . PHP_EOL;
    if($settings['remarksdisplay']==$var) {echo "EQUAL";} else {echo 'not equal';}
    echo PHP_EOL;
    
    ?>
    

    Sorry, I changed the Linebreaks to NewLine characters cause I tested it in CLI. The above code has the extra space after Great removed and it works just fine.

    So what was happening was basically that extra space threw off the count, as you can see the s:XX the number indicates how long the string is, that extra space made it 32 instead of 31 for the “Great Price” statement, since serialize needs to be accurate, it was throwing a Notice error, which most people do not show and why there were no errors coming through.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We just switched to our new website redesign. We have a copy of the
I just switched two projects over to fogbugz and so far I like it
We've just recently switched to VS 2010 and i had a solution that was
We've just recently switched over from SVN to Mercurial, but now we are running
I just got knocked down after our server has been updated from Debian 4
We just switched over to VS2010, and I remember a while back I had
I just switched over from iPhone to Android and am looking for something similar
I just switched over from SVN where after a few changes to the trunk
I have a new web app that is packaged as a WAR as part
I just switched over from my development database to the production database, and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.