Page 1 of 1

query string

Posted: Mon Jun 20, 2005 9:06 am
by punksteve
For some reason, I can not access $QUERY_STRING.

Code: Select all

<?
ini_set("register_globals", "on");

echo "Query String = " . $_SERVER['$QUERY_STRING'];
?>

<?
if ($QUERY_STRING  == "About") {
?>
<p>
<strong>About Me:</strong>
<br/><br/>
<?php 
include("about.php");
?>
</p>
<?
}
?>
The echo always returns nothing, even if the address ends with ?Whatever

Posted: Mon Jun 20, 2005 9:14 am
by hawleyjr
print_r the $_SERVER variable to see what the query string is. Are you passing any vars through it?

Code: Select all

echo '<hr><pre>';echo print_r ($_SERVER).'</pre><hr>';

Re: query string

Posted: Mon Jun 20, 2005 10:37 am
by senthilnayagam
if this is the code you used

you made a small mistake

Code: Select all

echo "Query String = " . $_SERVER['$QUERY_STRING'];
you should have used

Code: Select all

echo "Query String = " . $_SERVER['QUERY_STRING'];
that additional data '$' caused all those problems,

regards

Senthil

Posted: Mon Jun 20, 2005 11:11 am
by punksteve
hawleyjr wrote:print_r the $_SERVER variable to see what the query string is. Are you passing any vars through it?

Code: Select all

echo '<hr><pre>';echo print_r ($_SERVER).'</pre><hr>';
Sorry, I forgot to include this in my post:

Code: Select all

&lt;a href=&quote;?About&quote;&gt;About&lt;/a&gt;&lt;br/&gt;
So when I click the link, the querystring should be "About"

Re: query string

Posted: Mon Jun 20, 2005 11:15 am
by punksteve
senthilnayagam wrote:if this is the code you used

you made a small mistake

Code: Select all

echo "Query String = " . $_SERVER['$QUERY_STRING'];
you should have used

Code: Select all

echo "Query String = " . $_SERVER['QUERY_STRING'];
that additional data '$' caused all those problems,

regards

Senthil

Thank you so much! I would have probably never caught that. Works like a charm now :)