Depreciated MySQL Connects with XAMPP and WordPress
Warning; If Doing PHP Development With WordPress locally, you can run into issues if you install PHP version 5.5.x onwards.
UPDATE: Since WordPress 3.9, PHP 5.5 and the MySQLi functions are now properly supported, so this article will no longer be relevant.
This, as I’ve just found, is because from PHP v5.5.x onwards, the MySQL* commands are depreciated. It’s also good practice to show ALL errors when developing PHP locally, and I’m not 100% sure, but I think v.5.5.x of PHP forces stops and makes you read depreciated errors anyway…
I found this out as I downloaded the very latest XAMPP PHP & Apache package from www.apachefriends.org. as I’d read that it’s a pretty good stack for doing your development locally on Windows. That 1.8.3 package installed PHP 5.5.x, which I thought all well and good. But when I then set-up a virtual domain and copied in the WordPress files and tried to run the ‘5 minute install’, all I saw was PHP error stacks.
I did some Google investigations, and it turns out that the dev team behind WordPress have been using the basic MySQL connect stuff since the dawn of time. Zend/PHP.net do tell you that you should have ported over to the ‘better’ MySQLI API’s, or use the Object PDO version.
“It is not recommended to use the old mysql extension for new development, as it has been deprecated as of PHP 5.5.0 and will be removed in the future”
But the team behind the WordPress core will not be looking to change over to one of the other methods until at least version 3.8 (we are only ‘just’ on version 3.6.. so we are some months away yet, possibly a year or more at time of writing).
So the only thing to do was to un-install XAMPP 1.8.3 and go with the 1.8.2 version, which uses PHP 5.4.x instead. It’s not a fantastic move, but I want to get on and NEVER TOUCH THE CORE CODE IN WORDPRESS. That’s the number one rule of WordPress development!
So away I go again – hopefully I’ll get a clean WordPress installation running locally (I have MANY remotely as you can see in my portfolio page). Then I can start to tinker with things – writing my own custom theme, and/or new plugins. I’m reading up on the ‘WordPress Loop’, and the WordPress API – I have a new book “Professional WordPress: Design and Development“, and another waiting.. in fact then a Pro PHP book.. and a MySQL admin/development guide… and a few more. I’m starting soon as Development Lead at New Scientist, so am brushing up… and want some books to put on my new desk 🙂