I made a query to other site. An array is returned. However, which information is inside is not sure.
Suppose the array normally contains
A["a"],A["b"],A["C"]
but sometimes some of them might be missing. Therefore I got this kind of error message:
============================
Notice: Undefined index: author in /home/public_html/catalog/admin/insert_one.php on line 149
============================
Is there anyway I can let PHP ignore the missing, perhaps simply treat it as blank, without aborting the program?
undefined index
Moderator: General Moderators
- Tiancris
- Forum Commoner
- Posts: 39
- Joined: Sun Jan 08, 2012 9:54 pm
- Location: Mar del Plata, Argentina
Re: undefined index
You can deactivate that message using error_reporting() at the top of your script:
More info about error_reporting(): http://php.net/manual/en/function.error-reporting.php
Code: Select all
// Report all errors except E_NOTICE
error_reporting(E_ALL ^ E_NOTICE);
Re: undefined index
Ya, turning off E_NOTICE is a band-aid at best.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.