Undefined index QUERY_STRING... kind of lost...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
danf_1979
Forum Commoner
Posts: 72
Joined: Sun Feb 20, 2005 9:46 pm

Undefined index QUERY_STRING... kind of lost...

Post by danf_1979 »

Hi:

Following some advice in here, I enabled error_reporting = E_ALL in my server. I found some notices about variables and fixed them. I dont know how to fix this one though:


Notice: Undefined index: QUERY_STRING in /var/www/web25/web/catalog/class.php on line 12

This is the script:

Code: Select all

$threats = array(";", "'", "AS ", "/**/", "/SELECT/","/UNION/" );
if (strpos($_SERVER['PHP_SELF'], "trackback") === false) {
	foreach($threats as $threat) {
		if(stristr($_SERVER['QUERY_STRING'], $threat)) {
			die("Hack!");
		}
	}
}
What is wrong ? Why doesn't recognize de QUERY_STRING?
gavinandresen
Forum Newbie
Posts: 8
Joined: Tue Mar 21, 2006 8:18 pm

Post by gavinandresen »

$_SERVER['QUERY_STRING'] isn't set. You can avoid the error by modifying the code to say:

Code: Select all

if(isset($_SERVER['QUERY_STRING']) and stristr($_SERVER['QUERY_STRING'], $threat)) {
danf_1979
Forum Commoner
Posts: 72
Joined: Sun Feb 20, 2005 9:46 pm

Post by danf_1979 »

Thanks, It works OK :)
Post Reply