Can't seem to turn off deprecated errors in php - php

Im on a development server using a version of php that doesn't support mysql_connect() our production server does. I have tried: error_reporting = E_ALL ^ E_DEPRECATED but it doesn't work. After restarting Apache I still the deprecated error message.
I have access to the ini file I should not need php functions to change the error reporting. this is also for wordpress.

error_reporting() is a function. Try: error_reporting(E_ALL ^ E_DEPRECATED ^ E_USER_DEPRECATED);. Or ini_set("error_reporting", E_ALL & ~E_DEPRECATED);. Then test the settings with echo ini_get("error_reporting");. Minimal PHP version must be 5.3.0 for that.

Try replacing your mysql_connect() with mysqli_connect()

Are you sure that you've modified the correct php.ini? Often there are several included with an install. Is this happening on your local development machine, or on a live server? The best way to make sure you've modified the right php.ini is to run a phpinfo file.
Create a new file, name it phpinfo.php and write:
<?php echo phpinfo(); ?>
Run this script in your browser and go down to the line that says "Loaded Configuration File"
This used to cause me headaches when using a WAMP install.

WordPress sets the error_reporting to E_ALL in its config files, thus overriding whatever you've set in php.ini. I beleieve setting error_reporting(E_ALL ^ E_DEPRECATED) in wp-config.php clears it up. See Turn off deprecated errors php 5.3 for various and sundry variations on that setting.

setting: define('WP_DEBUG', false); to false fixed the issue.

Related

Error_reporting not affecting the error level

I'm trying to hide a deprecated warning on a site and so I've added error_reporting(E_ALL ^ E_DEPRECATED); but it's not having any effect. I've got the following test running:
error_reporting(E_ALL ^ E_DEPRECATED);
var_dump(E_ALL ^ E_DEPRECATED, error_reporting());
And the var_dump is outputting int(24575) int(32759), as you can see error_reporting isn't being set. I've also tried error_reporting(24575); just in case, and that didn't do anything either.
I've checked ini_get('error_reporting'); and that also returns 32759. Using ini_set('error_reporting', E_ALL ^ E_DEPRECATED); also doesn't change the error level.
A little more info about the server: It's a VPS configured through WHM used for development purposes. This site is running on PHP 5.6 FPM. The server was upgraded this morning to Easy Apache 4 to enable PHP 7, though 5.6 was left as an option for older sites such as this one.
Does anyone know why error_reporting isn't changing the error level? I've tried googling this but all I get are questions on how to get errors to show or hide, nothing on why error_reporting isn't changing the error level.
Turns out it was PHP-FPM, apparently it doesn't allow you to modify the configuration variables directly. The only place it can be changed is in the config file for PHP-FPM. I've disabled FPM for this site and it's working fine now.

I have disabled PHP Error reporting in php.ini but it continues to show in browser

So I have disabled PHP Errors inside my php.ini file (/etc/php5/apache2/php.ini) but they still continue to show in browser. I am running PHP version 5.5.9-1ubuntu4.13 and to do this I used the following:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_WARNING
display_errors = Off
display_startup_errors = Off
Examples of errors still showing include:
Warning: Creating default object from empty value ...
and
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in ...
Any help/advice as to why these errors may still be showing would be greatly appreciated. Thanks!
So I finally figured this out, with the help of Ukavi in the comments.
The errors started to display after I had transferred the site from one server to another, and it appears that the first server ran an older version of PHP which is why they did not show up before.
Anyway, the fix. I added this to wp-config.php:
error_reporting(0);
ini_set('display_errors', 'off');
I also did a find in files for ini_set and found a few instances where they had been deliberately activated. As this site is not a solo project I wasn't aware of this!
Thank you for all the advice guys.

Gocart codeigniter Installation issues

I have a problem with installing go cart on Linux live server cpanel
When i install go cart on Linux server the empty page occurred and nothing happens
Please can someone help me?
Turn on error reporting in php.ini.
In ubuntu php.ini is here: /etc/php5/apache2/php.ini
Try to search lines like this
; error_reporting
error_reporting = XXXXXXXXX
and replace to :
error_reporting = E_ALL & E_NOTICE & E_STRICT
See also http://pl1.php.net/function.error_reporting
#edit
You can also add following code to script:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
This might be because you don't have the php_intl extension enabled on your server, which gocart requires (from version 2.3 I believe). Without error reporting on, all you will get is a white screen.
If you have access to your php.ini file, make sure this line is uncommented;
extension=php_intl.dll
If you don't have access to the php.ini file, then you will need to ask your hosts if they can enable this for you.

PHP errors make page inaccessible

Every time I have an error within my code and try to run it, the page becomes inaccessible. This is clearly very frustrating as it's hard debugging code with no feedback.
Relevant information from cPanel:
Apache version 2.2.22
PHP version 5.3.14
MySQL version 5.1.68-cll
Architecture x86_64
Operating system linux
If more information is required then please ask, I'm sorry I cannot provide any more information but frankly I am stumped.
Thanks.
Enable error reporting to see what error PHP had, if it had one.
There are several places you can look, firstly try checking your Apache error log. In many cases this is located in /var/log/apache2/error.log . Another way to debug a page like this is to enable error logging.
The simplest way of doing this being adding these lines to your php file:
ini_set('display_errors',1);
error_reporting(E_ALL);
In addition to this, you can also clean up the errors formatting by adding:
ini_set('html_errors', 'On');
In addition to this method of enabling error reporting, you may also enable them from you configuration file by adding the following line:
error_reporting = E_ALL
You need to update your php.ini to display errors. There are a couple settings.
Search your php.ini for display_errors and error_reporting. The file is usually commented very well on the options for error reporting, but error_reporting = E_ALL is a typical setting. Sometimes people want to suppress notices and set error_reporting to E_ALL & ~E_NOTICE.
display_errors = On is the config to print the errors to the screen.
After changing your php.ini, Apache usually needs to be restarted. I'm not sure how much control you have over your server, so if you can't restart Apache but you have a php.ini available, your host probably has it configured so you don't need to restart.

Deprecated warning only in some php5 environments?

We're moving from php4 to php5, and we get this warning on one of our developers machines, but not in our php5 test setup:
Deprecated: Call-time pass-by-reference has been deprecated in C:\Workspace\Prelive\www\includes\filename etc..
The code seems to be the same in both environments, and the php.ini on the test environment has this setup for errors:
error_reporting = E_STRICT | E_ALL
We could ofcourse just fix the code so the warning will go away, but my main concern is why the test environment is not complaining about it.
There is a php.ini directive called allow_call_time_pass_reference, which may be off in the environment which does not complain about it.
You've probably checked this already, but is
display_errors = On
set in both ini files?

Categories