views:

36

answers:

2

I'm working with one array that have 55 elements inside and each one are another array with 17 elements each one.

When I show the array on the screen, nothing wrong happens but when I take a look in the page source, I have 55 x 17 "Severity: Notice" errors with the message "Undefined index".
Does someone know what can be wrong?

If the index really doesn't exist, I couldn't see the array on the screen.

I tested using if ( isset( ) ) { ... }, but still the same.

Codeigniter version: 1.7.2
Browsers tested: firefox, chrome, ie and safari.

+1  A: 

I usually get this errors when I'm trying to echo something that is not defined. It's not an PHP error, only a notice. This is produced by the function error_reporting(); on the main index.php.

If you open this index.php file, you will see:

/*
|---------------------------------------------------------------
| PHP ERROR REPORTING LEVEL
|---------------------------------------------------------------
|
| By default CI runs with error reporting set to ALL.  For security
| reasons you are encouraged to change this when your site goes live.
| For more info visit:  http://www.php.net/error_reporting
|
*/
    error_reporting(E_ALL);

You've two options:

  1. Don't print a variable that is not defined.
  2. Change the error_reporting(); with a non-notice prints. Like: error_reporting(E_ALL & ~E_NOTICE);.

Wish this helps you!

Isern Palaus
Thanks but still the same. Now I have another message in the page source, after I upload a file. The message says "You did not select a file to upload", but the file was uploaded.
Derick
Try, instead of isset(), if(isset($var) AND $var != NULL) { }
Isern Palaus
It is better to use empty(); it returns true if the variable is undefined, or if it is an empty array, or if it is false or null or 0. So !empty($var) is what I'm really trying to determine.
Mitchell McKenna
A: 

This has nothing to do with CI or your browser, it is a classic PHP notice.

Ferdy
Can you show us the path to the light?
Derick
As the answer below mine suggests, you can output PHP warnings, notices, etc. These notices will indicate the line number in your code where the notice originated from. That allows you spot the problem, most likely it is indeed the case of using an index that does not exist.
Ferdy