View Full Version : Query Strings - detecting and accessing

02-20-2003, 01:57 PM
Can any one tell me how to access a query string and how to test if it exists?

I know about using $_SERVER['QUERY_STRING'] but I want to just get the value at the end of the query string

eg - page.php?id=2 - just want the "2".

I am also having problems checking to see if the querystring exists in the first place. This is the code I have so far. If I manually append the query string in the address bar, then it works fine, jumps to the "else" statement etc. But without it it just fails.

$memid = $_SERVER['QUERY_STRING'];

if (!isset($memid))
printf("no query string");


02-20-2003, 02:42 PM
You know you can access the querystring variables using:


(In the case of page.php?id=2)

This will give you the "2".

Then you can see if it exists using:

IF (!isset($_GET[id])){
echo "id = $_GET[id]";
} else {
echo "No id";

Other than that I don't really understand what you are asking.


02-20-2003, 03:02 PM
Bingo! No, that's fine, that was exactly what I was asking.

Thanks a lot :)

02-20-2003, 03:44 PM
Glad i could be of help :D

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum