Remove Undefined index error

Hi i am getting this undefined index error in almost everything i do . i have googled it and removed by adding the line
error_reporting(E_ERROR|E_WARNING);

but do i need to change the php.ini file for it or am i missing something while coding,owing to the fact that i am getting it on almost everypage ??

Hi there,

I prefer to fix errors rather than hide them. If you are doing something along the lines of:
[php]$getvar = $_GET[‘term’];[/php]

If that GET variable doesnt exist, the command will fail. Instead change them to the following for the same values but no errors:
[php]$getvar = isset($_GET[‘term’]) ? $_GET[‘term’] : ‘’;[/php]

but what if the term exists and i know this fact as i have coded and assigned a name to that very same term …and i am still getting the error .

Show us some code and we can help you track it down.

The Undefined Index error means that you are referencing an element of an array that does not exist. So, either something is spelled wrong, or some logic error is preventing the element from being created in the first place.

Hiding errors, instead of fixing them is a good way to create buggy code that will come back to haunt you later.

Sponsor our Newsletter | Privacy Policy | Terms of Service