if(isset($_REQUEST['page'])) { $pagename = $_REQUEST['page']; } else { $pagename = 'home'; }
Should work... If not, let us know. Make sure your case match, too. ?page=hello and ?Page=hello are two different variables. ---John Holmes... ----- Original Message ----- From: "Brian Dunning" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, February 03, 2003 11:54 AM Subject: [PHP] Need to check whether a param exists! Hi, All I'm trying to do is check for the presence of a query string, but everything I try gives me an Undefined Index error. I want to set a variable $pagename to whatever was passed as the ?page= value, and if it wasn't passed, set it to some default value. http://www.mysite.com/index.php?page=hello <?php if (is_object($_REQUEST['page'])) $pagename = $_REQUEST['page']; else $pagename = "home"; ?> I also tried is_null, tried if($_REQUEST) by itself, also tried all of these with $_GET, $_POST, $_GLOBAL, but they all give me Undefined Index error on that If line. - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php