Page 1 of 1

"Parse error: parse error"

Posted: Mon Aug 17, 2009 3:05 pm
by sheppardzwc
All of my PHP errors are coming up as

"Parse error: parse error in ____ on line ___"

How can I make them more descriptive (display the actual error)? I'm running Apache2.2/PHP5.3 on Windows Vista localhost.

Re: "Parse error: parse error"

Posted: Mon Aug 17, 2009 3:40 pm
by califdon
I'm afraid that's about as descriptive as PHP error messages usually get. You can make sure that your error level is set as high as possible, but that's about it. If it's a parse error, it should be pretty clear what's wrong when it points you to the specific line (although the actual error is often a line or two earlier, but doesn't create an error until it has gone on to the next line). See http://www.addedbytes.com/php/php-ini-g ... d-logging/
also http://www.linuxquestions.org/questions ... ..-433706/

Re: "Parse error: parse error"

Posted: Mon Aug 17, 2009 3:55 pm
by jackpf
I think PHP error messages are amazingly helpful compared to other languages'.

Re: "Parse error: parse error"

Posted: Mon Aug 17, 2009 8:53 pm
by sheppardzwc
Well, like this here.

My server:

Image

vs.

A friend's dedicated linux: http://ariact.org/forum/includes/functions.sql.php

Re: "Parse error: parse error"

Posted: Mon Aug 17, 2009 9:34 pm
by jackpf
Oh right...I see what you mean.

Do you have error messages turned on in php.ini?

And lol...that guy has a parse error in like every script....

Re: "Parse error: parse error"

Posted: Mon Aug 17, 2009 10:13 pm
by sheppardzwc
jackpf wrote:Oh right...I see what you mean.

Do you have error messages turned on in php.ini?

And lol...that guy has a parse error in like every script....
Never said I was a GOOD coder. rofl.

Code: Select all

; Common Values:
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards warnings.)
;   E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
;   E_ALL | E_STRICT  (Show all errors, warnings and notices including coding standards.)
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_NOTICE
 
; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; It's recommended that errors be logged on production servers rather than
; having the errors sent to STDOUT.
; Possible Values:
;   Off = Do not display any errors 
;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)   
;   On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On
 
; The display of errors which occur during PHP's startup sequence are handled
; separately from display_errors. PHP's default behavior is to suppress those
; errors from clients. Turning the display of startup errors on can be useful in
; debugging configuration problems. But, it's strongly recommended that you
; leave this setting off on production servers.
; Default Value: Off
; Development Value: On
; Production Value: Off
; http://php.net/display-startup-errors
display_startup_errors = On

Re: "Parse error: parse error"

Posted: Tue Aug 18, 2009 5:56 am
by jackpf
Hmm...you've got errors turned on.

What happens if you run:

Code: Select all

<?php
foo();
?

Re: "Parse error: parse error"

Posted: Tue Aug 18, 2009 7:13 am
by Eran
by the way, it's best to work with STRICT while developing
E_ALL | E_STRICT
Check your apache error log, you might see something relevant in there.

Re: "Parse error: parse error"

Posted: Tue Aug 18, 2009 10:18 am
by sheppardzwc
My apache error log details the actual error, just doesn't display it on the page.

[Mon Aug 17 23:17:15 2009] [error] [client 127.0.0.1] PHP Parse error: parse error, expecting `')'' in C:\\forum\\includes\\config.php on line 14, referer: http://server/includes/

And it displays fatal errors. Like foo().

Fatal error: Call to undefined function foo() in C:\forum\foo.php on line 3

But what about parse errors?

Re: "Parse error: parse error"

Posted: Tue Aug 18, 2009 10:55 am
by jackpf
Stuff like this:

Code: Select all

<?php
$var = 'foo'
$var2 = 'something else'
//notice no semi-colons
Will just say "parse error on line...". It does that for me as well.

Re: "Parse error: parse error"

Posted: Tue Aug 18, 2009 2:59 pm
by Weirdan
jackpf wrote:Will just say "parse error on line...". It does that for me as well.
It says

Code: Select all

 
Parse error: syntax error, unexpected T_VARIABLE in /home/weirdan/q.php on line 3
 
here when running your snippet. It must be something wrong with your configuration.

Re: "Parse error: parse error"

Posted: Tue Aug 18, 2009 2:59 pm
by Eran
what OS, apache version and PHP version are you running?

Re: "Parse error: parse error"

Posted: Tue Aug 18, 2009 3:11 pm
by jackpf
Oh right...I thought that was normal.

I'm on Windows XP, Apache 2.2, PHP 5.3.

How odd.