Link to home
Start Free TrialLog in
Avatar of jimgordon
jimgordon

asked on

How to solve undefined index notices

Hi,
I am trying to fix a lot of undefined index notices in my classified ads php website. I've read lots of post here, and I thought that it is easy to remove those notices, just using isset(). In effects, notices disappears, but some times the script stops from working as it should. Can someone explain, in general and in poor words, how to manage this notice? E.g., "use isset if you deal with a $_ variable, or use empty if you deal with a $var variable" and so on? (if it is possible to write a rule like that, I don't even know!)
Avatar of gamebits
gamebits
Flag of Canada image

You can always put at the topof your page

error_reporting(0);

this will hide all the notices warnings and errors, in case of a major error (an error that will break the script) you will end up with a blank page.

Not exactly a good programing tactic but rather a quick fix.
Avatar of jimgordon
jimgordon

ASKER

Yes, I know. My intent is to fix those notices, not to hide them.
Then you need to use the isset() function or to assign a default value at the top of the script, value to be use by the script if the variable is not overwritten by a $_POST['var'] value.
Why if variable is not a $_ ? E.g.: let's pretend variable is 'x'.
Can I still use isset?
The problem is that I'm looking for a general rule, since I have spent all day in adding isset() in front of those variable that caused notices, and  at the end I've found that lots of thing don't work anymore properly.
ASKER CERTIFIED SOLUTION
Avatar of gamebits
gamebits
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the problem is that aI have a lot of these notices all around the website. I cannot post here notice by notice. Is there a way to hire someone of you here and pay for a finished job?
I don't think it's in accordance with EE rules to post a paid job offer, but I know as a programmer we can can post our email address in our profile and I know some offer to tackle projects.

What is the website all about? How many pages? Is it a script that you bought and try to modify? May be they offer some kind of support if it's the case.
Yes, I purchased this script from a developer, but i don't think he would solve these notices for me only. It is a classified ads script you can see at www.annunci.cc. It is about 90 pages (less than 1Mb). Page affected are less than 90, anyway.
Beside EE there is quite a few website where you can post a project and have programers bid on it

www.rentacoder.com
www.php-freelancers.com
www.getafreelancer.com
www.scriptlance.com

are a few of them
The script is Italian so I guess the comment in the script are also written in Italian, having a programer who is fluent in the language might help a lot fixing those issue for you.
No, the script is entirely in english. I only changed the language file. I can send you the english file if you need.