"Parse error: parse error"

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
sheppardzwc
Forum Newbie
Posts: 20
Joined: Mon Aug 17, 2009 3:04 pm

"Parse error: parse error"

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: "Parse error: parse error"

Post 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/
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: "Parse error: parse error"

Post by jackpf »

I think PHP error messages are amazingly helpful compared to other languages'.
sheppardzwc
Forum Newbie
Posts: 20
Joined: Mon Aug 17, 2009 3:04 pm

Re: "Parse error: parse error"

Post by sheppardzwc »

Well, like this here.

My server:

Image

vs.

A friend's dedicated linux: http://ariact.org/forum/includes/functions.sql.php
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: "Parse error: parse error"

Post 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....
sheppardzwc
Forum Newbie
Posts: 20
Joined: Mon Aug 17, 2009 3:04 pm

Re: "Parse error: parse error"

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: "Parse error: parse error"

Post by jackpf »

Hmm...you've got errors turned on.

What happens if you run:

Code: Select all

<?php
foo();
?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: "Parse error: parse error"

Post 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.
sheppardzwc
Forum Newbie
Posts: 20
Joined: Mon Aug 17, 2009 3:04 pm

Re: "Parse error: parse error"

Post 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?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: "Parse error: parse error"

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: "Parse error: parse error"

Post 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.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: "Parse error: parse error"

Post by Eran »

what OS, apache version and PHP version are you running?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: "Parse error: parse error"

Post by jackpf »

Oh right...I thought that was normal.

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

How odd.
Post Reply