0
isset($_SERVER['QUERY_STRING']) always returns true?
LEGEND
,
/t5/dreamweaver-discussions/isset-server-query-string-always-returns-true/td-p/1028596
Jul 01, 2006
Jul 01, 2006
Copy link to clipboard
Copied
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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/isset-server-query-string-always-returns-true/m-p/1028597#M195014
Jul 03, 2006
Jul 03, 2006
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
LATEST
/t5/dreamweaver-discussions/isset-server-query-string-always-returns-true/m-p/1028598#M195015
Jul 03, 2006
Jul 03, 2006
Copy link to clipboard
Copied
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/
> 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/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

