The Joyent Community

A place where the Joyent community can gather, help each other out, and stay informed.

You are not logged in.

#1 2004-06-11 13:12:47

nissarup
King of Danish
From: Copenhagen, Denmark.
Registered: 2004-06-02
Posts: 419
Website  Expertise

… make PHP-errors show?

Right now, I don't get anything when there is an error in my PHP-scripts. JUst an empty page.
I tried setting error_reporting to E_ALL and display_errors to on via webmin, but it doesn't seem to work.
Its quite difficult to debug PHP, or any code for that matter, if you don't know where the error is :)

Offline

 

#2 2004-06-11 13:20:52

DaveSeidel
Member
From: New Hampshire, US
Registered: 2004-06-01
Posts: 134
Website  Expertise

Re: … make PHP-errors show?

One thing I do is to install a copy of PHP on my PC. Then, before I upload a page, I check it for syntax errors like this:

php -l mypage.php

(the flag is a lowercase 'L', as in "lint")

This won't help with runtime issues, but it's a very good first level check that it will at least compile.

Another usefull technique is to put echo() statements in your code, but have it priint eveything as an HTML comment, e.g., echo("<-- my debug message -->\n");.

Last edited by DaveSeidel (2004-06-11 13:21:11)


That gum you like is going to come back in style.

Offline

 

#3 2004-06-11 13:23:45

nissarup
King of Danish
From: Copenhagen, Denmark.
Registered: 2004-06-02
Posts: 419
Website  Expertise

Re: … make PHP-errors show?

Im moving the code from my old server to the new. The only thing I changed was the database info, so the code should run. Only Im not getting any output at all :/

Offline

 

#4 2004-06-11 13:51:54

DaveSeidel
Member
From: New Hampshire, US
Registered: 2004-06-01
Posts: 134
Website  Expertise

Re: … make PHP-errors show?

What is the file extension you're using? Maybe it's something that isn't mapped to PHP by default on TXD.


That gum you like is going to come back in style.

Offline

 

#5 2004-06-11 13:55:18

nissarup
King of Danish
From: Copenhagen, Denmark.
Registered: 2004-06-02
Posts: 419
Website  Expertise

Re: … make PHP-errors show?

Its something.php
If I make a new something.php file with just an echo command it compiles fine and echoes the correct string, but if I, on purpose, deletes the last ) I just get no output. Just an empty website. And I viewed the source of the page. No output. No errors, zip, nada. This is beginning to bug me.

I tried putting in several die() statemnts but I just cant figure out where the error is. If only I could turn on errors in php...

Offline

 

#6 2004-06-11 14:00:06

Dean
Administrator
From: Languedoc
Registered: 2004-05-29
Posts: 844
Website  Expertise

Re: … make PHP-errors show?

Nis, pop the following at the top of your script:

ini_set("display_errors","1");


Text*

Offline

 

#7 2004-06-11 14:05:22

nissarup
King of Danish
From: Copenhagen, Denmark.
Registered: 2004-06-02
Posts: 419
Website  Expertise

Re: … make PHP-errors show?

Still no go.

I made a small test script here: http://kasselotteriet.dk/hej.php
See the source here: http://kasselotteriet.dk/hej.phps

Offline

 

#8 2004-06-11 14:08:05

nissarup
King of Danish
From: Copenhagen, Denmark.
Registered: 2004-06-02
Posts: 419
Website  Expertise

Re: … make PHP-errors show?

I just deleted the changes I made to PHP in webmin. So everything should be back to normal. There is no .htacces file in my pupblic_html folder. There is a .htaccess file in a subfolder, but that shouldnt interfere with this script.

Offline

 

#9 2004-06-11 14:22:06

DaveSeidel
Member
From: New Hampshire, US
Registered: 2004-06-01
Posts: 134
Website  Expertise

Re: … make PHP-errors show?

That source fikle you posted has an incomplete statement:

echo('Hej'

should be

echo('Hej');

unless you did that deliberately to try to get an error message...


That gum you like is going to come back in style.

Offline

 

#10 2004-06-11 14:23:54

Dean
Administrator
From: Languedoc
Registered: 2004-05-29
Posts: 844
Website  Expertise

Re: … make PHP-errors show?

Okay, it should work if you put:

ERROR_REPORTING(E_ALL);
ini_set("display_errors","1");

The hej.php example script wasn't giving anything because the unencapsulated string led straight to the closing ?> - so the server wasn't parsing it as PHP at all.


Text*

Offline

 

#11 2004-06-11 14:24:12

nissarup
King of Danish
From: Copenhagen, Denmark.
Registered: 2004-06-02
Posts: 419
Website  Expertise

Re: … make PHP-errors show?

It was on purpose :)

Offline

 

#12 2004-06-11 14:27:03

nissarup
King of Danish
From: Copenhagen, Denmark.
Registered: 2004-06-02
Posts: 419
Website  Expertise

Re: … make PHP-errors show?

Indeed it does. How do I put them in a .htacces file?
I tried this:
php_value display_errors on
php_value error_reporting E_ALL

But it didnt work.

Offline

 

#13 2004-06-11 14:33:25

Dean
Administrator
From: Languedoc
Registered: 2004-05-29
Posts: 844
Website  Expertise

Re: … make PHP-errors show?

I think for everyone's well-being and sense of security, you should expose PHP errors on a case-by-case basis. For example it's not impossible, with the right combination of errors, to fling your mysql password out there.


Text*

Offline

 

#14 2004-06-11 14:35:38

nissarup
King of Danish
From: Copenhagen, Denmark.
Registered: 2004-06-02
Posts: 419
Website  Expertise

Re: … make PHP-errors show?

Ok. I better not do that :)

Thanks for your help Dean & Dave.

Offline

 

#15 2004-06-11 14:58:43

jason
a chief (i started this place)
From: San Francisco
Registered: 2004-06-01
Posts: 8814
Website  Expertise

Re: … make PHP-errors show?

display_errors on isn't a good idea, and things are being written to your error log.

but the php_value error_reporting E_ALL should have dumped up what was going into etc/error_log

Offline

 

#16 2004-06-11 16:58:40

cczona
Member
From: California, US
Registered: 2004-06-02
Posts: 88
Expertise

Re: … make PHP-errors show?

nissarup wrote:

Indeed it does. How do I put them in a .htacces file?
I tried this:
php_value display_errors on
php_value error_reporting E_ALL

But it didnt work.

Did you call it literally ".htacces"? Because you're missing the second "s" there.

PHP config flags get confusing. According to the docs, display_errors is a PHP_INI_ALL so normally you would expect to use php_value for it. Except that display_errors is also a boolean, therefore you're supposed to use php_flag instead. See if one of these doesn't work better:

php_flag display_errors on
php_value display_errors 1

Also, it looks like E_ALL may not be valid in an .htaccess context (it's definitely not valid in httpd.conf). In which case, you're supposed to use the [url=http://www.php.net/manual/en/ref.errorfunc.php#errorfunc.constants]bitmask value 2047 instead. I hope this helps!
[/url].

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson