views:

33

answers:

1

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?

+4  A: 

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.

Wrikken
I also have other variables being requested and processed, and they are processed without error. It's just `sessid`.
Nik
Do you have `register_globals` enables, and are you using (and possibly unsetting) a `$sessid` variable somewhere?
Wrikken
`register_globals` is off, and `$sessid` is validated but that happens before it gets to the page that sends data to `methods.php`.
Nik
Solved. I had a typo in the form that submits `sessid`, and setting the method to `$_POST` worked.
Nik