----- Original Message -----
From: "Mike Tuller" <[EMAIL PROTECTED]>
To: "php mailing list" <[EMAIL PROTECTED]>
Sent: Friday, January 17, 2003 5:05 PM
Subject: [PHP] $HTTP_GET_VARS


> I am following an example in a book and have run into a problem with a
> script that I am trying to run under PHP 4.3.0. What I have is a page
> that you click on an id number that is from a listing in a database,
> and it is supposed to take you to a page to edit that item. I have the
> id sent in the url (http://127.0.0.1/asset/editasset.php?id=3) and the
> book says to use $HTTP_GET_VARS to take that id

Are you using $HTTP_GET_VARS['id']?  If it's in a function, then php scopes
$HTTP_GET_VARS as a local variable, and thus there's nothing in it.  While
that's different then most other programming languages, it's how it is in
php. If you want to reference the global $HTTP_GET_VARS in a function, then
you must 'global' it:

function foo() {
global $HTTP_GET_VARS;
echo "Id is {$HTTP_GET_VARS['id']}<br>\n";
}

Now the php developers added a new set of arrays to help with that in 4.1.2
(I think), so use $_GET['id'] which always references the builtin global
$_GET array. It's better.

i.e. Learn the new way and not the old way ...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to