php Error Reporting

Richard Korts
Richard Korts used Ask the Experts™
on
I am in the process of moving a large & complex site from another hosting company to GoDaddy. Yesterday, I was able to get it basically working; there was an issue with php generated emails, but for the most part, it worked.

Today, it behaves quite differently. Now, it is reporting php Warning errors, which I DO NOT want.

See attached jpg for example.

The GoDaddy people are clueless about this, so it occurred to me to change the php error reporting level. There was already a php.ini file there, I added the error_reporting parameter (see attached).

I Still get the same thing.

How can I suppress the php WARNING errors but keep the others?

Thanks
LSS-Menu.jpg
php.ini
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
if the server allows you to use php.ini, adding this is already enough:

date.timezone = "US/Central"
Correct allowed time zone strings are here: http://www.php.net/manual/en/timezones.php

If php.ini editing is not allowed, in the php file add

date_default_timezone_set('America/New_York');

Again, use same link for correct strings.
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
To Kimputer

The example I showed dealt with the php date() function; there are HUNDREDS of other Warning error messages.

I want to TURN OFF all warning messages.

Commented:
php.ini:


display_errors = off
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Most Valuable Expert 2011
Top Expert 2016

Commented:
The GoDaddy people are clueless...
And that is exactly why I do not recommend GoDaddy hosting.  The only time you need an interaction with a smart person at a hosting company is when things go wrong.  As you have seen, you cannot get this interaction at GoDaddy.

You never want to suppress the error messages.  Instead the right thing is to find out what is causing them and correct the underlying causes.  In this case, you've got a good answer to the date/timezone issue.

In a deployed application, a reasonable setting might include error_reporting(E_ALL) combined with ini_set('display_errors', FALSE) and ini_set('log_errors', TRUE). This would give you a record of the errors without showing them to the client browser.  If the error_log file appears in any of your directories, you can look at it and find out what went wrong.
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
Ray,

I applied your recommended settings to the php.ini file.

See attached.

I uploaded the file to the root folder of my account.

It still does the same thing.

What did I do wrong?
php.ini
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
It isn't just Godaddy, most 'tech support' people are 'clueless'... because they are told not to help you with programming because it takes Way too much time.  

Last time I checked, on Godaddy you needed to name your added 'php.ini' as 'php5.ini'.  And even that Only works on Linux hosting on Godaddy.  If you try to add a 'php.ini' file on Windows hosting, you have to add the Entire file... which of course is not available.

Also, I know that Godaddy is only up to PHP 5.3.  If you try to move the site to 'better hosting' with PHP 5.4 or 5.5, you will see some of those warnings become errors.  Always better to fix the errors and warnings before they become more difficult later.
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
To Dave Baldwin,

I saved the ini file as php5.ini & uploaded it.

Nothing changed, same Warning errors.

There must be something wrong with the error reporting lines in the ini file.

Thanks
Dave BaldwinFixer of Problems
Most Valuable Expert 2014
Commented:
Run 'phpinfo()' on that hosting and see what it says.  I am not having these problems on my Linux and Windows accounts on Godaddy.  You will have to fix the 'date' problem to make it go away.  I don't believe there is any 'error' setting that will make that one disappear.  

What are some of the other warning and errors?
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
It says error_reporting no value.

The current host is 1 & 1; the attached is a piece of the phpinfo there.

Note is says error_reporting 30719. What does that mean? Can I just say (in php.ini "error_reporting = 30719"?

I didn't look far enough, but, so far, the only other errors SEEM to be related to the timezone nonsense. For example:

Warning: mktime() [function.mktime]: It is not safe to rely on the system's timezone.
settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Denver' for 'MST/-7.0/no DST' instead in /home/rkorts1/public_html/schedappt2.php on line 88
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
I forgot to attach.
error-rpt-1and1.jpg
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
To all,

I changed the php.ini file to the attached; note the inclusion of the recommended date.timezone parameter, I saved this BOTH as php.ini and php5.ini.

The same problem still persists.

Is there something wrong with the php.ini?

Do I have to do something differently?

Thanks
php.ini
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Yes, you really need to move away from 1and1 hosting.  I just went to check a file on the only client account I have there... and instead of '404 Not Found', it put up an advertisement for Other Web sites.  Frankly 1and1 makes Godaddy look very good.
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
Yes, that's why I picked them, contrary to what some people say, before this fiasco, I have found their customer support to be EXCELLENT.

But I really need to solve the php.ini problem now.

Thanks
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
I don't think it's a 'php.ini' problem.  As I said, I don't believe you can get rid of the 'date' warning without simply fixing the problem.  And you have not posted any other warnings or errors that you are getting.  And by the way, when I checked the 1and1 account, they were still running PHP 4.4.9 which is Way out of date.  If the account you are transferring from was a PHP 4.4.9 account, you may have more surprises to come.
Most Valuable Expert 2011
Top Expert 2016

Commented:
1and1 makes Godaddy look very good
+1 for that.  Truth.
Most Valuable Expert 2011
Top Expert 2016
Commented:
I have only one active site on GoDaddy.  Here is the content of my php5.ini file, which is in the web root directory:
register_globals = off
allow_url_fopen = on

expose_php = Off
max_input_time = 1800
max_execution_time = 1800
variables_order = "EGPCS"
extension_dir = ./

precision = 12
SMTP = relay-hosting.secureserver.net
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="

log_errors = On
log_errors_max_len = 1024
error_log = error_log

display_errors = Off

session.bug_compat_warn = Off
session.bug_compat_42 = Off

session.save_path = tmp
upload_tmp_dir = /tmp

magic_quotes_gpc = Off

Open in new window

This INI has the effect of making the error display invisible (it's a deployed application) and writing the error messages to the error_log file.

Commented:
Please note that not all web hosters allow you to use your own php.ini file
Maybe the other user of GoDaddy just got lucky, and you landed on a server farm which doesn't allow it.
Try to set it during runtime (inside the php files):

error_reporting(0);
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
FYI, I will try to get GoDaddy to tell me WHY I can't use php.ini (or why it doesn't seem to take effect).
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
To all:

It turns out that at GoDaddy, the php.ini file has to be called .user.ini (with the leading . like .htaccess

That MAY be just for my plan (Ultimate with Cpanel) because the rep first told me that it had to be php5.ini.

Also, the item date.timezone = "US/Arizona"; does NOT work, maybe the syntax has to be different?

Just FYI.
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Here is the list of supported Time Zones: http://us1.php.net/manual/en/timezones.php  America/Phoenix is probably the only one that works for Arizona since it does not support Daylight Savings Time.
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
Thanks, Dave.

In the individual php programs, I am using date_default_timezone_set('US/Central');

This works; no errors. I am just going to put this in an include & include it in ALL programs.

Not sure where the "Arizona" came from.
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
"US/Central" is listed Only for backwards compatibility.  http://us1.php.net/manual/en/timezones.others.php

You could use "America/Chicago" .  http://us1.php.net/manual/en/timezones.america.php

The 'standard' time zones that you may be thinking of do not correspond to the 'legal' time zones that have been implemented.  Arizona, for example, really does have it's own time zone for Date and Time purposes that is different than it's neighboring states.
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
Thanks Dave; that may be why it does not work.

But I'm preparing to bail ship at GoDaddy; their support in this case ranges from clueless to trying to be helpful but still not able to resolve issues.

Richard
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
You will not get much help from any hosting company for coding issues.  That's you ask questions here.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial