Re: [PHP] How to check for a $_GET without throwing a Notice?

2004-05-27 Thread Burhan Khalid
Brian Dunning wrote:
How do I check for the presence of an optional $_GET param without 
throwing a Notice: Undefined index when the param is not present?

Tried all three of these, they all produce the Notice when the param is 
not passed:

if ($_GET['id'])
if ($_GET['id'] != )
if (isset $_GET['id'])
if (@$_GET['id'])
http://www.php.net/manual/en/language.operators.errorcontrol.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] How to check for a $_GET without throwing a Notice?

2004-05-26 Thread Brian Dunning
How do I check for the presence of an optional $_GET param without 
throwing a Notice: Undefined index when the param is not present?

Tried all three of these, they all produce the Notice when the param is 
not passed:

if ($_GET['id'])
if ($_GET['id'] != )
if (isset $_GET['id'])
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How to check for a $_GET without throwing a Notice?

2004-05-26 Thread Richard Davey
Hello Brian,

Wednesday, May 26, 2004, 4:01:30 PM, you wrote:

BD How do I check for the presence of an optional $_GET param without
BD throwing a Notice: Undefined index when the param is not present?

BD Tried all three of these, they all produce the Notice when the param is
BD not passed:

BD if ($_GET['id'])
BD if ($_GET['id'] != )
BD if (isset $_GET['id'])

if (isset($_GET['id']))
{
   $id = $_GET['id'];
}

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I am not young enough to know everything. - Oscar Wilde

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



Re: [PHP] How to check for a $_GET without throwing a Notice?

2004-05-26 Thread John W. Holmes
From: Brian Dunning [EMAIL PROTECTED]

 How do I check for the presence of an optional $_GET param without 
 throwing a Notice: Undefined index when the param is not present?
 
 Tried all three of these, they all produce the Notice when the param is 
 not passed:
 
 if ($_GET['id'])
 if ($_GET['id'] != )
 if (isset $_GET['id'])

if(isset($_GET['id']))

or

if(!empty($_GET['id']))

depending upon what you want to do.

---John Holmes...

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



Re: [PHP] How to check for a $_GET without throwing a Notice?

2004-05-26 Thread Daniel Clark
if (isset( $_GET['id']))

How do I check for the presence of an optional $_GET param without 
throwing a Notice: Undefined index when the param is not present?

Tried all three of these, they all produce the Notice when the param is 
not passed:

if ($_GET['id'])
if ($_GET['id'] != )
if (isset $_GET['id'])

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





RE: [PHP] How to check for a $_GET without throwing a Notice?

2004-05-26 Thread Rick Fletcher
 How do I check for the presence of an optional $_GET param without 
 throwing a Notice: Undefined index when the param is not present?
 
 Tried all three of these, they all produce the Notice when 
 the param 
 is not passed:
 
 if ($_GET['id'])
 if ($_GET['id'] != )
 if (isset $_GET['id'])
 

 if (isset( $_GET['id']))

As a general note, isset( $array[key] ) returns false if $array[key] ===
NULL.  You should use array_key_exists( key, $array ) instead.

--Rick

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



Re: [PHP] How to check for a $_GET without throwing a Notice?

2004-05-26 Thread Tyler Replogle
aslo you could change it to something else like this
$_GET['id'] = $id;
if (!$id) {
// whatever you want to happen put here
}
From: Daniel Clark [EMAIL PROTECTED]
Reply-To: Daniel Clark [EMAIL PROTECTED]
To: Brian Dunning [EMAIL PROTECTED],[EMAIL PROTECTED] 
[EMAIL PROTECTED]
Subject: Re: [PHP] How to check for a $_GET without throwing a Notice?
Date: Wed, 26 May 2004 10:59:20 -0700

if (isset( $_GET['id']))
How do I check for the presence of an optional $_GET param without
throwing a Notice: Undefined index when the param is not present?

Tried all three of these, they all produce the Notice when the param is
not passed:

if ($_GET['id'])
if ($_GET['id'] != )
if (isset $_GET['id'])

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


_
MSN Toolbar provides one-click access to Hotmail from any Web page – FREE 
download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/

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