WP 3.6: mysql_connect deprecated ?

I get this error while i only use the wpdb functions.

Anyone knows something about this?

Are you on PHP >5.5? mysql_connect and a bunch of the other mysql functions are deprecated in this version in favor of PDO. From the changelog:

mysql: This extension is now deprecated, and deprecation warnings will be generated when connections are established to databases via mysql_connect(), mysql_pconnect(), or through implicit connection: use MySQLi or PDO_MySQL instead Dropped support for LOAD DATA LOCAL INFILE handlers when using libmysql. Known for stability problems Added support for SHA256 authentication available with MySQL 5.6.6+

WP can’t deprecate PHP functions, in this case extensions. Can’t believe authors with silver paws don’t know the verry basics.

SyamilMJ said

Are you on PHP >5.5? mysql_connect and a bunch of the other mysql functions are deprecated in this version in favor of PDO. From the changelog:

mysql: This extension is now deprecated, and deprecation warnings will be generated when connections are established to databases via mysql_connect(), mysql_pconnect(), or through implicit connection: use MySQLi or PDO_MySQL instead Dropped support for LOAD DATA LOCAL INFILE handlers when using libmysql. Known for stability problems Added support for SHA256 authentication available with MySQL 5.6.6+

Yeah i read that. But i was thinking - it’s not me using that function since i use the wpdb class AND i’m not even conntecting to a different database or something. So it’s WP itself using that function and then giving a warning?

i find i strange… there are tons of plugins and themes using the wpdb in a proper way and they all get that warning?

Ah well, i see you’ll have to put out queries and stuff in the PDO way ( or mysqli ).

Anoying update :slight_smile: , but probably necessary

If you’re on PHP 5.5, then the warning came from PHP, not WP.

The wpdb class naturally uses mysql_connect so the warning came from the use of that class specifically, see - http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/wp-db.php#L1144

Plugins/themes don’t have anything to do with the warnings, since the class was instantiated by the core itself.

You can suppress this warning - http://php.net/manual/en/function.error-reporting.php

use something like error_reporting(E_ALL ^ E_DEPRECATED);

Hey SyamilMJ,

I only got the warning after updating to WP 3.6.
So guess this means the warning comes from WordPress ?

So, they have to fix the wpdb class?

Technically, no.

WP has in-house error suppressing (you turn this on using WP_DEBUG), so the more logical explanation is they decided to not suppress E_DEPRECATED errors anymore in v3.6

Ah ok, so the warning shown could still be a warning from php.

But WP gives WPDB as the proper way to use direct database access and creation of own plugin tables etc. Now i’m wondering, how to use PDO in WP properly instead? Can’t find anything about this. I know how to setup a DB connection with PDO in PHP, but it seems to me there should be some sort of build in WP class like WPDB to use PDO.

Well, turns out it hadn’t anything to do with my plugin! Haha

You were right, it’s just a php deprecated warning that they don’t suppress anymore, cuz the warning also shows in a new blank WP install.

So my worries about the whole WPDB thing were not correct.

So, everyone who uses PHP from a certain version and up will always get these warnings in WP when working in debug mode, sounds really anoying…

So, everyone who uses PHP from a certain version and up will always get these warnings in WP when working in debug mode, sounds really anoying…

Agreed. Maybe you can try sending a trac ticket to address this issue. 5.5 has less than 0.1% market share so it’s possible that they didn’t think this through.

or just edit your php.ini file…

Turns out that deprecated messages already were suppressed on my server.
I’ve tried various settings in my php.ini but nothing worked.

Looks like WordPress is overriding these settings at runtime in the code ( found error_reporting() lines in multiple core files ).

So, this is really anoying - i have the latest php 5.5.1 version, so i think i’m gonna downgrade to 5.4 or something since there’s nothing i can do against those warning. annoying move by WP

Update: i’ve downgraded to php 5.4 and the message is gone.

@SyamilMJ : Hi - I’m using your wonderful Aqua Page builder plugin and, besides this mysql_connect error (Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in …\wp-includes\wp-db.php on line 1142) , I get these two errors, appeared only after 3.6 upgrade:

Deprecated: Assigning the return value of new by reference is deprecated in ... \wp-content\plugins\aqua-page-builder\aq-page-builder.php on line 68

Strict Standards: Redefining already defined constructor for class AQ_Block in ... \wp-content\plugins\aqua-page-builder\classes\class-aq-block.php on line 27

Any ideas ?

Thanks in advance …

EDIT: my php is v 5.5.0 … :confused:

aligatorstudio said

@SyamilMJ : Hi - I’m using your wonderful Aqua Page builder plugin and, besides this mysql_connect error (Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in …\wp-includes\wp-db.php on line 1142) , I get these two errors, appeared only after 3.6 upgrade:

Deprecated: Assigning the return value of new by reference is deprecated in ... \wp-content\plugins\aqua-page-builder\aq-page-builder.php on line 68

Strict Standards: Redefining already defined constructor for class AQ_Block in ... \wp-content\plugins\aqua-page-builder\classes\class-aq-block.php on line 27

Any ideas ?

Thanks in advance …

EDIT: my php is v 5.5.0 … :confused:

Than it is indeed just PHP 5.5 making the warning beacause of WP core. Nothing wrong with the plugin.

Yeah, but on 3.5.2 WP version these notices didn’t appear. So, for (near) future-proofing, it would be recommended to solve this (WP core and themes/plugins authors).

So, how to make those errors disappear ?

WP_DEBUG must be on as many theme buyers are actually developers too … And they are (at least, serious ones) can’t ignore notices, as we shouldn’t too …

aligatorstudio said

Yeah, but on 3.5.2 WP version these notices didn’t appear. So, for (near) future-proofing, it would be recommended to solve this (WP core and themes/plugins authors).

So, how to make those errors disappear ?

WP_DEBUG must be on as many theme buyers are actually developers too … And they are (at least, serious ones) can’t ignore notices, as we shouldn’t too …

if you give the whole thread a good read, then you’ll see there’s nothing to fix by plugin authors.

It’s just that WordPress 3.6 doesn’t suppress PHP deprecated warning anymore, and that’s why you get those warnings if you have PHP 5.5 . It are PHP deprecated messages, generated by WP core. So, there’s nothing to do except for WP to replace the deprecated PHP functions one day…

Like said, PHP 5.5 has very very low market share so far so it’s a matter of time WP will change these functions. In the meanwhile, there’s nothing you can do but downgrade to PHP 5.4.

It’s no big deal, there nothing to ‘ignore’. DEBUG mode must be on one development servers yes, but never on live sites.

So, serious developers have plenty of reasons to develop on PHP 5.4 or even 5.3. Specially since 5.5 is still rarely used on most hosting ( specially shared hostings used by most buyers ).

aligator, i just pushed an update to theme which should fix those issues. But it won’t make the mysql_connect issue go away though, as it’s not coming from the plugin. See - http://themeforest.net/forums/thread/aqua-page-builder/77590?page=5#859343

Cheers

SyamilMJ said

aligator, i just pushed an update to theme which should fix those issues. But it won’t make the mysql_connect issue go away though, as it’s not coming from the plugin. See - http://themeforest.net/forums/thread/aqua-page-builder/77590?page=5#859343

Cheers

Thanks SyamilMJ, I just upgraded the plugin. I know that mysql_connect is php5.5/WP 3.6 issue, and I'm sure that WP guys will deal with that. In the meantime, I downgraded my server back to php 5.3 and the deprecation notice is gone.

Great work, man !
I wish you all the best ! :slight_smile: