For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > September 2004 > Undefined index: orderBy









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Undefined index: orderBy
Hamish McCracken

2004-09-24, 8:56 pm

Hi,

I have the following code to determine how I want my results (pulled from a
database) ordered.

if (!$_GET['orderBy']) {
$orderBy = "startDate";
} else {
$orderBy = $_GET['orderBy'];
if ($orderBy=="") {
$orderBy = "startDate";
}
}

I can't remember (been a while since I've used php) how to determine whether
or not a query string variable is present and if it isn't return a value for
the defined variable. At the moment, when no query string is present I get
the error: Notice: Undefined index: orderBy

When there is a query string, obviously there is no error.

Many thanks in advance.

Cheers

Hamish


Janwillem Borleffs

2004-09-24, 8:56 pm

Hamish McCracken wrote:
> I can't remember (been a while since I've used php) how to determine
> whether or not a query string variable is present and if it isn't
> return a value for the defined variable. At the moment, when no query
> string is present I get the error: Notice: Undefined index: orderBy
>


www.php.net/isset


JW



Lāʻie Techie

2004-09-27, 3:55 am

On Sat, 25 Sep 2004 01:00:56 +0200, Janwillem Borleffs wrote:

> Hamish McCracken wrote:
> www.php.net/isset


how about array_key_exists?

HTH,
La'ie Techie

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com