i am developing a site in WordPress and, i am using PHP version 5.6 and i have faced this error:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/c118209438/public_html/wp-includes/wp-db.php on line 1578
i want to hide this error , for that i used these lines but it does not give me appropriate output ...
error_reporting(0)
error_reporting(E_ALL &~ E_DEPRECATED);
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED
thanks for advance ...
Related
My server is running PHP 5.3 and my WordPress install is spitting these errors out on me, causing my session_start() to break.
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 647
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 662
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 669
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 676
Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 712
This is annoying, but I do not want to turn off on screen error reporting. How do I disable these bothersome deprecated warnings?
I am running WordPress 2.9.2.
You can do it in code by calling the following functions.
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
or
error_reporting(E_ALL ^ E_DEPRECATED);
To only get those errors that cause the application to stop working, use:
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
This will stop showing notices, warnings, and deprecated errors.
I needed to adapt this to
error_reporting = E_ALL & ~E_DEPRECATED
You have to edit the PHP configuration file. Find the line
error_reporting = E_ALL
and replace it with:
error_reporting = E_ALL ^ E_DEPRECATED
If you don't have access to the configuration file you can add this line to the PHP WordPress file (maybe headers.php):
error_reporting(E_ALL ^ E_DEPRECATED);
I just faced a similar problem where a SEO plugin issued a big number of warnings making my blog disk use exceed the plan limit.
I found out that you must include the error_reporting command after the wp-settings.php require in the wp-config.php file:
require_once( ABSPATH .'wp-settings.php' );
error_reporting( E_ALL ^ ( E_NOTICE | E_WARNING | E_DEPRECATED ) );
by doing this no more warnings, notices nor deprecated lines are appended to your error log file!
Tested on WordPress 3.8 but I guess it works for every installation.
All the previous answers are correct. Since no one have hinted out how to turn off all errors in PHP, I would like to mention it here:
error_reporting(0); // Turn off warning, deprecated,
// notice everything except error
Somebody might find it useful...
In file wp-config.php you can find constant WP_DEBUG. Make sure it is set to false.
define('WP_DEBUG', false);
This is for WordPress 3.x.
I tend to use this method
$errorlevel=error_reporting();
$errorlevel=error_reporting($errorlevel & ~E_DEPRECATED);
In this way I do not turn off accidentally something I need
If PHP warnings are breaking things in WordPress, but you still want to know what the warnings are, you can disable displaying PHP errors/warnings and only send them to the log file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
this error occur when you change your php version: it's very simple to suppress this error message
To suppress the DEPRECATED Error message, just add below code into your index.php file:
init_set('display_errors',False);
I want to supress warning from this trigger_error('Deprecated', E_USER_DEPRECATED); in runtime. From I have read I can use error_reporting(E_ALL & -E_USER_DEPRECATED & -E_DEPRECATED);. But that does not work. I tried if error_reporting works in general by using error_reporting(0). This works. What did I miss? I did not find another way to solve my problem. And did not notice that this way does not work for someone else.
My code which does not suppress deprecated warning:
error_reporting(E_ALL & -E_USER_DEPRECATED);
trigger_error('Deprecated', E_USER_DEPRECATED);
Php version: 7.0.14.
You have a syntax error in the value for error_reporting(). To exclude certain errors you need to use the tilde symbol ~ instead of the dash -:
error_reporting(E_ALL & ~E_USER_DEPRECATED);
// ^ this one
trigger_error('Deprecated', E_USER_DEPRECATED);
I have installed a fresh new Typo3 installation.
I have Windows 7 and use Apache 2.4
PHP 5.6.11 with Zend Engine 2.6.0 and with Xdebug v2.3.3.
Typo3 uses their own error handler so it is possible to control the error levels in the configuration file. However the mysqli still throws warnings for mysqli::init() and mysqli::stmt_init(). In both cases the error are
PHP Warning: mysqli::stmt_init(): Property access is not allowed yet in W:\typo3\sysext\core\Classes\Database\DatabaseConnection.php on line 782
PHP Warning: mysqli_init(): Property access is not allowed yet in W:\typo3\sysext\core\Classes\Database\DatabaseConnection.php line 1190
I have tried to read the thread mysqli + xdebug breakpoint after closing statment result in many warnings but it seems the warning is related to some bugs in mysqli. As what I read these bugs should be resolved.
Since these errors comes from the core of Typo3 I think it will be foolish to edit in the DatabaseConnection.php file.
However, I have tested my connection using mysqli::__construct instead of mysqli_init(). mysqli::__construct does not throw any warnings/errors. http://php.net/manual/en/mysqli.construct.php
In typo3conf/LocalConfiguration.php I have set errorHandlerErrors and exceptionalErrors to 30965 instead of 30466 such that Typo3 does not trows an exception for warnings. This only solved the problem for mysqli_init() - not stmt_init().
So what can I do?
The problem is solved by set the error reporting level to E_ALL except E_STRICT in php.ini.
That is because the built in error handler in Typo3 is more sensitive that default error handler.
error_reporting(E_ALL ^ E_STRICT);
I was getting this error since I was using a third party application using mysql_ prefix.
Deprecated: The mysql extension is deprecated and will be removed in
the future: use mysqli or PDO instead in /path/to/filename.php on line
123
So i tried to hide this error by editing my php.ini file. I have tried adding
error_reporting = E_ALL ^ E_DEPRECATED;
But that didn't work.
So I tried this
error_reporting(E_ALL ^ E_DEPRECATED);
That too didn't work. What may be the issue? Is it with my php.ini file, or am I doing it wrong. Please let me know the correct method to hide this deprecated error message (or what was wrong with the methods i used).
You need to logically AND the negated E_DEPRECATED flag in order to disable it:
error_reporting(E_ALL &~ E_DEPRECATED);
Try this to deprecate error messages of 3rd third party tools.
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
Anyone knows how to solve the error below?
Deprecated: Function ereg() is deprecated in C:\wamp\www\includes\file.inc on line 895
It is happening after installing Drupal 6.13 on wamp server 2.0i with PHP 5.3.0
Use
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);
Instead of
ereg('\.([^\.]*$)', $this->file_src_name, $extension);
Drop your error reporting level below E_DEPRECATED.
PHP 5.3 introduced two new error reporting levels, E_DEPRECATED and E_USER_DEPRECATED and - for the first time in PHP's history - they've started to walk away from older parts of their API. The ereg_* function will still work, but this warning is intended to let you know that "hey, these function will be going away soon, probably in the next major revision).
Just add # in front of the function. e.g.
#ereg()
more issue relating upgraded your web servers which running PHP 5.3.0, pls refer
http://www.rain-forest-forum.com/dotproject-net-installation-issues-t263.html
This is not a Drupal issue.In the Drupal site it is noted that it does not yet support PHP 5.3 and there have been new error flags added to PHP.
Solution1 : You can degarde the PHP version.You can revert back to PHP 5.2.x. As I am unsure of other conflicts with Drupal and PHP 5.3.
Solution2 : However, if you prefer to keep PHP 5.3, you can always suppress the deprecated function errors. In Drupal’s includes/common.inc,
Find the line :
if ($errno & (E_ALL ^ E_NOTICE)) {
And replace it with:
if ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) {
This will now always suppress the Deprecated error messages.
One solution is to upgrade the offending sourcecode :-)
It's explained here: http://drupal.org/node/514334#comment-2852940
You can edit you common.inc file to quietly disregard the deprecated error flags. See my post:
http://funkinetics.org/klink/function-ereg-is-deprecated-error-in-drupal-6x-with-php-53/
Looks like the problem is with PHP 5.3.0. You could try downgrading to 5.2.9 as suggested by this drupal link: http://drupal.org/node/514334
Because I don't have time to update legacy code, I addeded following line to php code to suppress warnings.
error_reporting(E_ALL ^ E_DEPRECATED);
this line suppress only deprecated warnings. other errors are shown as usual.