Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

isset($_SERVER['QUERY_STRING']) always returns true?

LEGEND ,
Jul 01, 2006 Jul 01, 2006
hi:

i have this code wich always is returning true for
isset($_SERVER['QUERY_STRING']) even when calling the page without
passing vars through the url

$thisURL = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$qs = 1;
$thisURL .= "?".$_SERVER['QUERY_STRING'];
}

for example, typing in the browser:
http://mac.local/~admin/.../home.php

echoes:
PHP_SELF: /~admin/.../home.php
QUERY_STRING:
$thisURL: /~admin/.../home.php?

do i need to unset $_SERVER['QUERY_STRING']???

OSX 10.4, PHP 5.0.4

tia,

jdoe
TOPICS
Server side applications
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 03, 2006 Jul 03, 2006
I don't like using isset(), had various problems with it on different
systems.

Try changing isset() to strlen() ie

if(strlen($_SERVER['QUERY_STRING']) > 0){

}

And see if that works, will only be true if there are actually some
characters contained in $_SERVER['QUERY_STRING']

Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 03, 2006 Jul 03, 2006
LATEST
gareth wrote:
> I don't like using isset(),

isset() tells you whether the variable has been defined - nothing more,
nothing less.

The correct way to test without generating any errors or notices is this:

if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {

--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines