Page 1 of 2

List of PHP Error meanings?

Posted: Sun Jan 31, 2010 5:32 pm
by Kismet
As I work my way through the tutorials, I usually make a mistake or two and get an error message. That's ok, but I really wish I knew what the error messages meant. Because it's very hard to find a mistake when you don't have any idea of what you've done wrong :roll:.

Anyway, I've searched Google, but I couldn't find anything. So does anybody know of a site that lists all of the PHP errors and tells you what they mean? It would really be a big help.

Thanks muchly.

Re: List of PHP Error meanings?

Posted: Sun Jan 31, 2010 6:23 pm
by Animatro
Im not sure if there is a list of errors.. But here is a few I know of.

Parse Error: Forgotten a bracket, quotation mark, curly brace.
Unexpected End: I think this may fall under parse error, but if your page finishes loading before an if statement is closed you'll get this.
Undefined Index: Trying to access part of an array that hasn't been set yet. This usually comes up if you store data from the database in an array. If you select only the Username from the database and try to echo $Data['Email'] you will get this.
Expecting T_FUNCTION: Again I think this comes under a parse error, but this usually comes up for me when I forget a semi colon. (;).

Those are the most common errors I've came across, but your best bet is to take the error you get and google the actual error part of it. Like if you get the error
Notice: Undefined index: najsh in C:\wamp\www...
try googling "PHP Undefined Index". That usually works for me. Hopefully this post will have helped somewhat..

Re: List of PHP Error meanings?

Posted: Sun Jan 31, 2010 6:28 pm
by Jackolantern
Do you mean errors like "Parse error", "undefined variable", etc.? There is no exact translation, because the PHP interpreter is not that smart. All it can say is that it cannot understand something and it gives the reason why it can't understand. It doesn't always point to the exact issue. However, here is what I have figured out, and how I begin to look for my bugs:

1. Parse error: You have misspelled something in a place where PHP expects a keyword. This could also be from forgetting an ending bracket, or having too many because you have now interrupted the pattern that PHP is following which will cause it to read your code wrong.
2. Undefined variable: You have likely added an illegal character to a variable name, or you are trying to access an undefined superglobal. Since PHP is weakly-typed, you will not get this error for regular variables that have not yet been assigned a value. When you mention the variable, it is automatically generated with an empty value.
3. Incorrect parameters: You have tried to call a function without enough parameters, or too many.
4. Expecting ';': You forgot to add a semi-colon at the end of a statement.

Those are the 4 I get most often, in that order. There are others, but they are mostly self-explanatory. For me, PHP actually seems pretty good about pointing me directly to the error with pretty relevant error messages, especially in fairly simple code.

Re: List of PHP Error meanings?

Posted: Sun Jan 31, 2010 9:53 pm
by ZeroComp
undefined index is a problem with an associative array or whatever its called and you fix it like this [level] to ['level']

Re: List of PHP Error meanings?

Posted: Sun Jan 31, 2010 9:57 pm
by OldRod
It can also occur if you are referencing a table's field that does not exist

Re: List of PHP Error meanings?

Posted: Mon Feb 01, 2010 6:03 am
by Kismet
Aha! Yep that helps me a lot. Thanks guys!

It's a shame there isn't a 'central database' of errors, it would make life so much easier. I could just look up the error and the most likely cause of it.

But this will have to do. Thankyou all again :mrgreen:.

Re: List of PHP Error meanings?

Posted: Mon Feb 01, 2010 6:16 am
by Jackolantern
Be careful what you wish for. Back in the old days of C programming, the only error reporting and handling you had at your disposal was a global error number variable. If your program just stopped functioning, you had to check it and see which of the hundreds of error codes you got and read its cryptic meaning. No line numbers, no file references, nothing. It was a very hard time lol

Re: List of PHP Error meanings?

Posted: Mon Feb 01, 2010 10:07 am
by OldRod
And back then you couldn't Google it :)

Re: List of PHP Error meanings?

Posted: Mon Feb 01, 2010 11:29 am
by Kismet
Hehehe be careful, your age is showing :lol:.

Re: List of PHP Error meanings?

Posted: Mon Feb 01, 2010 4:41 pm
by hallsofvallhalla
hahaha *cough* 'cobol' *cough* :)

yeah this is a good topic. Thanks for the input here.