-2

keep getting this error , can someone explain & help me ..

Notice: Undefined index: error in C:\wamp\www\test\index.php on line 13

the code :

<?php
include "inc/config.php";
include "inc/template.php";

head($title);
openbody($title);
?>
<h1>Sistem Maklumat Kekosongan Jawatan</h1>
<h3>JobsMalaysia Center Danga Bay</h3><br />
<br />
<?php
$err = get_error($_GET['error']);
echo '<p>'.$err.'</p>';
?>
<?php   
closebody();
?>
Zeko
  • 15
  • 1
  • 2

1 Answers1

0

The $_GET super-global doesn't contain the key error, it should be fairly self-explanatory.

You can bypass the error by using:

<?php
if(isset($_GET['error']))
{
    $err = get_error($_GET['error']);
    echo '<p>'.$err.'</p>';
}
?>
BenM
  • 52,573
  • 26
  • 113
  • 168
  • I personally would make it a little more clean by doing something like this: http://ideone.com/b46OhZ So you can abstract out the isset part a little more. Just a personal preference. – Jessica Jan 08 '14 at 17:45
  • I don't think that there's any point in extracting that code into a separate function. `isset()` is already sufficient, why would you want to wrap everything in another function call? – BenM Jan 08 '14 at 17:48
  • Because A. eventually he's going to want to add more to it and B. you can make it one line of code to use multiple places instead of 3. – Jessica Jan 08 '14 at 17:50