PHP在偏移量处反序列化错误,可在某些服务器上运行,而不是在其他服务器上运行 [英] PHP unserialize error at offset, works on some servers, not others

查看:111
本文介绍了PHP在偏移量处反序列化错误,可在某些服务器上运行,而不是在其他服务器上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有可以在少数服务器上使用的代码,但是在其他要处理序列化数据的服务器上却没有.我叫这样的页面:

I have code that works on a handful of servers, but not others which is coming up with serialised data. I call a page like this:

http://domain/index.php/sales/Drilldowns?params=a:12:{s:13:"selectionType";s:8:"facility";s:8:"dateType";s:5:"daily";s:10:"dateOption";s:9:"drilldown";s:6:"metric";s:13:"bookingAmount";s:9:"companyFK";s:2:"11";s:10:"facilityFK";s:0:"";s:7:"classFK";s:0:"";s:15:"customDateStart";s:4:"null";s:7:"newDate";s:10:"2010-11-01";s:10:"metricName";s:10:"Bookings%20$";s:16:"currentDateRange";s:10:"11/01/2010";s:23:"currentMetricNavigation";s:8:"DELDELTE";}&getExcel=0

这是我正在使用的代码:

This is the code I'm using:

protected function getRequestVariables(){
        if(isset($_REQUEST['params'])){
            var_dump($_REQUEST['params']);
            echo 'length:'.strlen($_REQUEST['params']);
            $vars = unserialize($_REQUEST['params']);
            var_dump($vars);
        } else {
            $vars = $_REQUEST;
            // unset saved drilldown options
            $this->ci->session->svar_set('postVars', null);
        }

这是var_dump输出:

string(447) "a:12:{s:13:\"selectionType\";s:8:\"facility\";s:8:\"dateType\";s:5:\"daily\";s:10:\"dateOption\";s:9:\"drilldown\";s:6:\"metric\";s:13:\"bookingAmount\";s:9:\"companyFK\";s:2:\"11\";s:10:\"facilityFK\";s:0:\"\";s:7:\"classFK\";s:0:\"\";s:15:\"customDateStart\";s:4:\"null\";s:7:\"newDate\";s:10:\"2010-11-01\";s:10:\"metricName\";s:10:\"Bookings $\";s:16:\"currentDateRange\";s:10:\"11/01/2010\";s:23:\"currentMetricNavigation\";s:8:\"DELDELTE\";}"

处理该错误时,会出现以下错误:

When that gets processed I get the following error:

遇到PHP错误
严重程度:注意 消息:unserialize()[function.unserialize]:偏移量6为447字节时出错
文件名:plugins/Drilldowns.php
行号:93

A PHP Error was encountered
Severity: Notice Message: unserialize() [function.unserialize]: Error at offset 6 of 447 bytes
Filename: plugins/Drilldowns.php
Line Number: 93

我正在5.2.13上尝试此操作-可在某些Linux,某些OS X而不是其他操作系统上工作.检查了php.ini,charset(我认为)-我一生都无法解决.我已经尝试过像

I'm trying this on 5.2.13 - works on some Linux, some OS X, not others. Have checked php.ini, charset (I think) - I can't figure it out for the life of me. I've tried things as simple as

string(18) "a:1:{s:3:\"sam\";}" length:18

,它仍然会出错.有什么线索吗?

and it still errors. Any clue as to why?

推荐答案

这是引号前面的反斜杠:\"

It's the backslashes in front of the quotes: \"

删除它们后,它会起作用.

When you remove them, it works.

var_dump(unserialize('a:12:{s:13:"selectionType";s:8:"facility";s:8:"dateType";s:5:"daily";s:10:"dateOption";s:9:"drilldown";s:6:"metric";s:13:"bookingAmount";s:9:"companyFK";s:2:"11";s:10:"facilityFK";s:0:"";s:7:"classFK";s:0:"";s:15:"customDateStart";s:4:"null";s:7:"newDate";s:10:"2010-11-01";s:10:"metricName";s:10:"Bookings $";s:16:"currentDateRange";s:10:"11/01/2010";s:23:"currentMetricNavigation";s:8:"DELDELTE";}"'));

可以在其上运行的服务器可能已打开魔术引号.

The servers this works on, probably have magic quotes turned on.

这篇关于PHP在偏移量处反序列化错误,可在某些服务器上运行,而不是在其他服务器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆