[PHP] Notice: Undefined index

Last update on July 6, 2009 07:01 AM by jak58
Published by jak58

[PHP] Notice: Undefined index










When using $ _POST or $ _GET to retrieve the variables from a form , you may encounter this error:
Notice: Undefined index 'fields of the table' in 'path of php file being executes' on line 'current line'

To avoid this error , simply test whether the fields of the table was initialized with the function isset ().
// Before using $_POST['value']
if (isset($_POST['value']))
{
          // Instructions if $_POST['value'] exist
}

This type of error is notified depending on the configuration of the server.
It is not notified by default as it is considered as a minor error, corresponding to the constant E_NOTICE.

You can change the types of errors reported with the error_reporting function.