Results 1 to 4 of 4

Thread: [resolved] If querystring exists?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Resolved [resolved] If querystring exists?

    Hello all.
    Code:
    <?php
    switch ($_GET['lang']) {
    case "es":
    	$txtGreeting = array("buenas dias");
    	break;
    case "fr":
    	$txtGreeting = array("bon jour");
    	break;
    default:
    	$txtGreeting = array("good day");
    }
    ?>
    The above code works just fine when I click on a link such as:
    Code:
    <a href="index.php?lang=fr">French</a>
    But if I click a link without the querystring (?lang=fr), I receive a nasty error message:

    "Undefined index: lang"

    Could anyone explain to me how to determine if a querystring exists BEFORE performing the switch statement?
    Or, if possible, how I could switch to default if the querystring is absent?

    Many thanks.
    Last edited by solitario; May 27th, 2005 at 02:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width