Cannot turn error messaging on

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SoreE yes
Forum Commoner
Posts: 32
Joined: Wed Oct 11, 2006 3:59 am

Cannot turn error messaging on

Post by SoreE yes »

I had someone write a php script for me, but it kept coming up with an error, so he turned errors off. Great. Like if there is a warning light indicating some problem, turn off the light. Problem solved. Anyway I can't turn it back on. I don't know what he did to turn it off. I've tried changing the error messaging in php.ini (both in the current directory and in the oringal php directory). I've also tried turning it on in the page script, but to no avail. What next?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Post the directives you put in the php.ini, htaccess files, and the original php file itself ...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Asking the person what they did?

There are two things to look for: error_reporting and display_errors

Look for both in php.ini, .htaccess files (including parent directories) and within your scripts.

Step 2, shoot the person that wrote it. :D
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

and search for @

Code: Select all

// no warnings when $r is not a valid resource
@mysql_fetch_array($r) 

// supresses _all_ warnings when executing yadda.php
@include 'yadda.php';
SoreE yes
Forum Commoner
Posts: 32
Joined: Wed Oct 11, 2006 3:59 am

Shoot the person who wrote it

Post by SoreE yes »

feyd wrote:Step 2, shoot the person that wrote it. :D
What a good idea. I am based in Thailand at the moment and guns are plentiful. People shoot each other regularly, even over things trivial. One can get someone shot for as little as $100. But I think I'll let him off this time.
SoreE yes
Forum Commoner
Posts: 32
Joined: Wed Oct 11, 2006 3:59 am

Code included

Post by SoreE yes »

In the php.ini file, the active error directives are

Code: Select all

error_reporting  =  E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = on
track_errors = On
html_errors = On
The htaccess files are new to me. I searched on all files on my hard disc and all the htaccess files were not accessible and had not been modified for a number of years.

All of my php scripts are affected.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do you recall what errors you were getting?
SoreE yes
Forum Commoner
Posts: 32
Joined: Wed Oct 11, 2006 3:59 am

Errors forgotten

Post by SoreE yes »

I only briefly saw the errors that came up, before this chap made changes and don't remember what they were. I have just managed to speak to him on the phone. It's difficult because he is Thai with little English and I speak English knowing even less Thai. And at best he can be described as a 'man of few words'. But from the broken converstion it appears that he did change something in the php.ini file.

I have just noticed that in the phpMyAdmin, from the php information, where it shows the configuration settings for php Core, that display errors is turned off, both local and master. Does this indicate the present settings on my machine, or is it a reference guide?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Check all the way at the bottom of the php.ini - it's possible he's overriding the above values down there.

Also double check that there's no auto_prepend_file set - he might be setting a few things in there as well.
SoreE yes
Forum Commoner
Posts: 32
Joined: Wed Oct 11, 2006 3:59 am

Post by SoreE yes »

Kieran Huggins wrote:Check all the way at the bottom of the php.ini - it's possible he's overriding the above values down there.

Also double check that there's no auto_prepend_file set - he might be setting a few things in there as well.
.

Thanks Kieran. Done that and nothing seems out of place.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Is it logging errors to a file? Look for errors.txt or something similar.

If you can't find one, paste this and run it alone:

Code: Select all

lets_debug($this_damn_problem){
   this is soooo totally invalid!
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Run the following in a new file please. You don't need to show us the results, but you can use it to compare where your edited php.ini is and where php is reading it from. It will also tell you where your errors are being reported to.

Code: Select all

<?php

$eol = (php_sapi_name() == 'cli' ? "\n" : "<br />\n");
echo 'Config path: ', get_cfg_var('cfg_file_path'), $eol;
echo 'Error log: ', get_cfg_var('error_log'), $eol;

?>
After confirming you are editing the correct php.ini, you can set error_reporting to E_ALL.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

and while you're at it you can also set

Code: Select all

disable_functions = error_reporting,ini_set
If one of these functions is called in the script you will get a warning: function 'xyz' is disabled for security reasons on line N in path/to/file. Just in case the report level is changed within the script.
see http://de3.php.net/manual/en/features.s ... -functions
SoreE yes
Forum Commoner
Posts: 32
Joined: Wed Oct 11, 2006 3:59 am

It worked.

Post by SoreE yes »

It worked. Thanks. When I ran the script to show the location of the configuration file it came up with

Code: Select all

C:\WINDOWS\php.ini
I had been looking on the web for a script that might tell me the present configuration settings, or the location of the used configuration file, but could not find anything, so thanks for supplying one.
This little creature in the windows directory had eluded me and I still don't know why. I had performed a search on the hard drive for any file called 'php.ini' and only ones in the /php directory, the root directory and the more local directories came up in the search results. The one in the windows directory did not show. All the files look identical so I am baffled. Anyway, I'm happy and can now get on with some work.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

The location of the ini file often baffles Windows users. The most efficient way to figure out where the ini file is is to call phpinfo() and look for the ini file string. Glad to see you found the problem.
Post Reply