News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Dougal Campbell:
mysql vs mysqli in WordPress
March 07, 2014 @ 10:59:52

In his latest post Dougal Campbell shares his findings from a bug he was having with a plugin in WordPress. It revolved around the use of mysql or mysqli and errors being thrown to his logs.

The plugin had previously worked fine (it generates a sidebar widget), and I wasn't actively working on my site, so I wasn't really sure when it had quit working. In the course of debugging the problem, I discovered that the plugin was throwing warnings in my PHP error log regarding the mysql_real_escape_string() function. As a quick fix, I simply replaced all of those calls with WordPress' esc_sql() function. Voila, problem fixed.

He was interested in why this worked, though, and went digging in the code. As it turns out, the WordPress code tries to determine which mysql extension you have support for. As it turns out, his installation fit the "mysqli profile" so the "mysql_real_escape_string" wasn't available. To the WordPress users out there, he suggests esc_sql or $wpdb->prepare() instead.

0 comments voice your opinion now!
mysql mysqli wordpress escape string extmysql

Link: http://dougal.gunters.org/blog/2014/03/06/mysql-vs-mysqli-wordpress

blog comments powered by Disqus

Similar Posts

WebLogTools Collection: Preventing WordPress Plugins From Loading

DevShed: Performing Basic Tasks with MySQL 4.1 and Above, using mysqli with PHP 5

Eran Galperin's Blog: Profiling queries with Zend_Db and optimizing them by hand

Rob Allen: Throw an exception when simplexml_load_string fails

Christian Stocker\'s Blog: \"Wordpress hat den Blog-Hosting Markt versaut\"


Community Events

Don't see your event here?
Let us know!


laravel symfony2 podcast php7 series community opinion api performance install conference release configure part2 framework example introduction interview language application

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework