query string

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
punksteve
Forum Newbie
Posts: 3
Joined: Mon Jun 20, 2005 9:01 am

query string

Post 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
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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>';
User avatar
senthilnayagam
Forum Newbie
Posts: 17
Joined: Wed Jun 08, 2005 5:36 am
Location: Bangalore

Re: query string

Post 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
punksteve
Forum Newbie
Posts: 3
Joined: Mon Jun 20, 2005 9:01 am

Post 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"
punksteve
Forum Newbie
Posts: 3
Joined: Mon Jun 20, 2005 9:01 am

Re: query string

Post 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 :)
Post Reply