PHP errors not showing XP
Posted by: peggy (---.range86-151.btcentralplus.com)
Date: February 21, 2008 04:17PM

Trying to get all errors to show using PHP 5 including Undefined Variables for local debugging and development.

php.ini
display_errors On

E_ALL & E_STRICT

At the top of every script I have:
error_reporting(E_ALL);

And nothing shows up an error not even in the log files (I'm not that good)

So I tried in the top of everypage:

error_reporting(E_ALL);
error_reporting(0);
$logerrorstotext = '';
$logerrorstotext.= 'Error: ' . __FILE__ . "\n";
$logerrorstotext.= 'Line: ' . __LINE__ . "\n";
$logerrorstotext.= 'When: ' . date('D F j Y H:i') . "\n";
$logerrorstotext.= "---------------------------------------------------------------\n";
error_log($logerrorstotext, 3, 'errors.txt');

To write the error to my own text file which works but only shows up an error for this line:
$logerrorstotext.= 'Line: ' . __LINE__ . "\n";

Huh????


Is this a Windows thing???

Help.

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 21, 2008 04:23PM

well wat u posted is a mistake if u copied it from ur ini file


display_errors = On

it needs the = sign

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: peggy (---.range86-151.btcentralplus.com)
Date: February 21, 2008 04:28PM

Wow that was quick.
Sorry it is actually set at:

display_errors = On

My typo.

Any ideas why I have no reporting? I have restarted all services many times.
Wamp works fine aswell.

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 21, 2008 04:29PM

are u sure they are not there? just in white writing? iv seen it happen before


drag ur mouse over as if ur copying.....

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: peggy (---.range86-151.btcentralplus.com)
Date: February 21, 2008 04:37PM

Good point.
No still not there. Viewed source and still nothing.

When I chuck the same code on my web server running (red hat linux) and the same versions of PHP and MYSQL I see all the errors:

Undefined variables etc etc


Weird

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 21, 2008 04:38PM

send me a copy of ur php.ini file



Edited 1 time(s). Last edit at 02/21/2008 04:39PM by stevenmartin99.

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: peggy (---.range86-151.btcentralplus.com)
Date: February 21, 2008 04:54PM

On its way via PM
Thanks

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 21, 2008 05:30PM

i think ur editing the wrong php.ini file

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: peggy (---.range86-151.btcentralplus.com)
Date: February 21, 2008 10:05PM

Its definately the right one as changes I make to it affect phpinfo.php as soon as I have restarted all services.
Path is something like:
c:\wamp\bin\apache\apache2.2.6\

Its basically the wamp default .ini file with the change to error_reporting value.

Does it differ greatly from you're own ini?

Thanks

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 21, 2008 10:16PM

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT



i use this. everything else is the same

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 21, 2008 10:24PM

peggy trust me- your using the wrong file- even if it does show up on ur phpinfo



the right php.ini file is located at c:/wamp/bin/php/php

and not the one in c:/wamp/bin/apache/apache/bin

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: peggy (---.range86-151.btcentralplus.com)
Date: February 22, 2008 12:03AM

Yes working now.

error_reporting = E_ALL

did the trick, but I'm still not sure in which php.ini file this is being called from (I changed them all just to be sure)

Funny thing is that I created a php info file and placed it inside my site folder inside www

Called it and this is the path where the config is loaded from:

Loaded Configuration File C:\wamp\bin\apache\apache2.2.6\bin\php.ini

So is that the path?

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 22, 2008 12:08AM

no im sure it runs from php folder...


mabye just check it by turning errors off in them and find out which one does it.

phpinfo file is not always accurate- iv learned it the hard way..

ill look into it more tomoro if u like? id like to know why its showing it as apache and not php

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: peggy (---.range86-151.btcentralplus.com)
Date: February 22, 2008 12:26AM

This is an error I am getting:

[21-Feb-2008 23:18:16] PHP Strict Standards: getdate() [<a href='function.getdate'>function.getdate</a>]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() ......etc etc

Does this mean its using E_STRICT ?

This undefined variable returns no error:

<?php echo $ewedwed;?>

Boy I'm totally confused by this now.

Heh thanks for all your assistance in this. If you can dedicate more time to this it would be most appreciated.

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: February 22, 2008 12:42AM

iv no idea whats going on- e all shud show everyting but strict


and the types of errors ur lookig for is e notice which is part of e all


try


error_reporting = E_ALL &E_NOTICE & ~E_STRICT


if that doesnt work then i just dont know

sorry

Options: ReplyQuote
Re: PHP errors not showing XP
Posted by: peggy (---.range86-151.btcentralplus.com)
Date: February 22, 2008 01:13AM

Got it. It's now reporting as per what I need.

This is what I found through a bit of back and forth.

I can confirm that the version of Wamp I am using (latest) is definately using the php.ini file at:

C:\wamp\bin\apache\apache2.2.6\bin\php.ini

I tested this using a file that had some preset errors to trigger both Strict and Undefined Variable notices.

(1) <?php echo date('l jS F Y');?> - Which should trigger - "It is not safe to rely on the system's timezone....."

(2) <?php echo $ewedwed;?> - Which should trigger - "undefined variable"



error_reporting = E_STRICT

Shows error_reporting 2048 in phpinfo

Shows my script errors for (1) only

++++++++++++++++++++++++

error_reporting = E_ALL & E_STRICT

Shows error_reporting 0 in phpinfo

Shows no script errors at all

So this is probably incorrect syntax.......

++++++++++++++++++++++++

error_reporting = E_ALL

Shows error_reporting 6143 in phpinfo

Shows my script errors for (2) only

++++++++++++++++++++++++

error_reporting = E_ALL | E_STRICT

Shows error_reporting 8191 in phpinfo

Shows my script errors including both (1) and (2)



The last one is perfect for my needs and prints both types of errors to screen.

So for others don't rely on the Wamp console phpinfo file and place a <? phpinfo();?> inside your website folder under www just to be sure.


Thanks Steven Martin for going through this with me. I probably would have given up long ago on my own.

All the best.

Options: ReplyQuote


Sorry, only registered users may post in this forum.