Another Undefined Index (this one's defined though)

試著忘記壹切 提交于 2020-01-07 08:33:06

问题


Alright, PHP is throwing this error (in the log) and it's quite detrimental to the application.

PHP Notice:  Undefined index: sessid in methods.php on line 7

Yes, I'm aware of what this error means, what I cannot figure out is why it's obviously defined and saying it's undefined. Here is the relevant code in methods.php

$sessid = mysql_real_escape_string($_REQUEST['sessid']);

Now before you go off and say that "NO IT'S UNDEFINED!!!", here is the POST request to the methods.php (and yes, I'm also aware that $_REQUEST "can't be trusted").

method=r&room=general&sessid=d0sma94yw4r4cdckv2ufhb&qid=1276957562382

As you can see, the sessid is obviously defined and is being sent off to the methods.php. I just thought I'd throw in the relevant query here too.

mysql_query('UPDATE active SET time=\''.$timestamp.'\' WHERE sessid=\''.$sessid.'\'');

Yes, time is also defined as:

$time = time();

So, what is the issue here?


回答1:


Barring typos etc, if you have a version >= 5.3.0, you might want to check what request_order (or variables_order if request_order is empty) ini-setting is set to. If in none of those two the 'P' is set, the $_POST array will not be in $_REQUEST (and not even set it the 'P' is not in variables_order afaik). See: http://www.php.net/manual/en/ini.core.php#ini.request-order

If those 2 are allright, I'd say you have a logical error somewhere else, var_dump() the $_POST and $_REQUEST superglobals to check.



来源:https://stackoverflow.com/questions/3075819/another-undefined-index-this-ones-defined-though

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!