Forum Moderators: coopster

Message Too Old, No Replies

How to know what's wrong?

understanding errors

         

too much information

12:51 am on Aug 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Alright you PHP maniacs! help me out here. :)

I finally set up my Mac to run my first PHP script and I tried to run it and all I get is errors. I edit, the error says a different line and I start the sequence again. Problem is I now have a line that I don't know why it's wrong.

In ASP I get an error number and I can search and find a reason that the error occured, however in PHP I just get

Parse error: parse error, expecting `','' or `';'' in /Users/brownie/Sites/dog_day/dir.php on line 10

Is there a file I need to know about that will tell me what error actually occured? How do I know what I'm doing wrong?

waitman

1:07 am on Aug 16, 2003 (gmt 0)

10+ Year Member



Believe me, PHP error message are much more revealing than ASP error messages. I promise you.

You really need to look at the code. A parse error means that there is something wrong with syntax.

Perhaps you could post lines 9,10,11 and 12 and someone could spot the error.

Take care,

jamesa

2:45 am on Aug 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I read that error as it's expecting a comma or semi-colon on line 10. Forgetting to end with a semi-colon is pretty common. Same with not closing quotes or brackets. But often with these types of situations the problem actually occurs several lines before where the error is reported. So start at line 10 and work backwards.

lorax

3:29 am on Aug 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As jamesa says.

It's most likely a missing ';' at the end of line 9

jonknee

4:11 am on Aug 16, 2003 (gmt 0)

10+ Year Member



The line numbers are almost never right, but you just have to look back. The error will never be farther ahead.

willybfriendly

4:20 am on Aug 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Go looking for that missing semi. Count your blessings that it is in line 10 and not line 110. Parse errors are sometimes pretty frustrating since the error can be many, many lines before it generates the error.

WBF

waitman

4:44 am on Aug 16, 2003 (gmt 0)

10+ Year Member



hmmmm

most of the time a parse error reports the correct line, or it is the line before.

although sometimes it reports the line that is the end of the file. this happens when you do not close a curly bracket. I agree that these are usually the most difficult parse errors to discover and correct.

best,

too much information

4:50 am on Aug 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wow, great responses! I take a day off and the troops show up! I'll check my ';' situation. I'm just not used to the PHP process yet.

If I still can't get it I'll post my code. Although I have posted code before I don't like to because I don't like people thinking I want them to do my work for me, and because I like to try to figure things out on my own as much as possible.

Thanks for the pointers, I'll keep you posted.

lorax

9:11 pm on Aug 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> The line numbers are almost never right

My experience is quite the contrary. But it helps to understand how the PHP engine thinks. Like when it tells you the error is on line 244 - which is actually the last line of HTML code. The error was an open if/else statement. The more I work with PHP the more I like it. Not always sensible but usually fair. ;)