Jrgen wrote:
>
>$op = $_GET['op'];
>switch ( $op )
>
>PHP shoots a Notice Message telling me that there is an undefined index
>Undefined index: act in g:\apache_web\intern\looney\index.php on line 177
>
If there is not a get variable in the url you will get the warning.
>Ok, am i correct in assuming that it pops this message because $op is not
>defined as anything yet?
>
Yes,
>
>If so,should i always just do this
>
>$_POST['op'] = '';
>$op = $_GET['op'];
>switch ( $op )
>{
> //Code here
>}
>
If there is not a get variable callled "op" you should still get the
warning.
>$op = isset($_GET['op']);
>switch ( $op )
>{
> //Code here
>}
>
Now $op will be a boolean assigned the value true (if there is a get
variable called "op" in the url) or false if not. As $op will have a
value then there is no warning.
What I tend to do when I have an optional item of data is:
if (isset($_GET["op"])) [
$op = $_GET["op"];
}
else
{
$op = "no value"; // set to something you can test for in
your switch statement.
}
though there may be a better way.
>
>Best regards from Vienna,
>Jrgen
>
.. thanks, and best regards to you from Essex, England.
HTH
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php