Wizard4U
Wizard4U

Reputation: 4097

wamp - notice undefined offset

How to turn off this error in wamp:

notice undefined offset

I'd like to turn of just this error, but not all errors.

Upvotes: 0

Views: 14805

Answers (7)

Ahmad Sharif
Ahmad Sharif

Reputation: 4435

Go to This direction on windows OS C:\wamp\bin\apache\Apache2.4.4\bin Then open php.ini file by any editor recommended [sublime] in 514 line just paste this two lines.

;error_reporting = E_ALL
error_reporting = E_ALL & ~E_NOTICE

Upvotes: 0

Vaibs
Vaibs

Reputation: 2096

 error_reporting(E_ALL);
 ini_set('display_errors', 'On');
 ini_set('html_errors', 'Off');

:D

Upvotes: 0

Ankur Saxena
Ankur Saxena

Reputation: 639

error->notice undefined offset

main thing is remove the error on your script.Programmer always wish to design program which is error free instead of error hiding.

The array vales are not set, so when PHP is trying to access the value of those array keys it encounters an undefined offset.

$new_array = array('1','2','3');//If I have an array
//We can now access:
$new_array[0];
$new_Array[1];
$new_array[2];
//If we try and access
$new_Array[3];

we will get the same error-->error->notice undefined offset

Upvotes: 0

Wizard4U
Wizard4U

Reputation: 4097

php.ini => error_reporting = E_ALL & ~E_NOTICE

Upvotes: 0

Mike Sherov
Mike Sherov

Reputation: 13427

There are two issues at work here. One is what errors PHP reports, and the second is whether or not it displays those errors on the page (as opposed to the apache error log). If you'd like to turn off just NOTICES:

<?php
error_reporting(E_ALL & ~E_NOTICE);
?>

If you'd like to report the notices to your error log but not display them to the user, do this:

<?php
ini_set('display_errors','off');
?>

Note that turning off display errors will stop displaying ALL errors to the end user, and you'll need to look at the error log, usually located in /var/log/httpd/error_log to see any errors while testing.

Upvotes: 4

VolkerK
VolkerK

Reputation: 96149

(If you can't fix the code...) You can exclude notices by setting an reporting level x & ~E_NOTICE, e.g.

<?php error_reporting( error_reporting() & ~E_NOTICE );

or in your php.ini (or similar)

error_reporting=E_ALL & ~E_NOTICE

Upvotes: 3

Felix Kling
Felix Kling

Reputation: 816600

Have a look at error_reporting().

You could e.g. set the error reporting to

error_reporting(E_ERROR | E_WARNING | E_PARSE)

But better would be to actually check what is the cause of the Notice and fix it. Then you are on the save side.

E_NOTICE
Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.

Upvotes: 3

Related Questions