Still using the old MySQL driver? What you need to know about MySQLi…

Its time to upgrade from the PHP MySQL extension

The PHP MySQL extension was deprecated in PHP 5.5.0!

You should upgrade your code to use MySQLi at least, even better would be upgrading to PDO.

This post about selecting data uses PDO and has the full source code available for you.

But back to MySQLi

The “i” in mysqli stands for IMPROVED, its not only new it’s improved too.

If you are still using the plain old mysql driver you should check to see if you can use mysqli.

All you need is PHP 5.4 or greater and add that “i”!

Once you get to PHP 5.5 or above mysql will no longer be supported.

Your queries will run faster, be more efficient and you can make use of more great features like prepared statements and it’s object oriented interface.

If you are using a PHP framework like CodeIgniter, switching should be a breeze, you just need to add the “i”.

For example you might have this in your code:

$db['default']['dbdriver'] = 'mysqli';

If you aren’t using a framework, please consider upgrading your code, depending on your hosting company they might upgrade their PHP version without warning!

It has happened before!

Then you will need to be fixing and upgrading your code under pressure while your website is down!

How to join two MySQL database tables together in a simple SELECT statement

How to join two MySQL database tables together in a simple SELECT statement?
For example I have a table of products and a table of product categories, how to return the category description of each product?


A. In it’s simplest form you would join two tables based on the relationship between a key and it’s foreign key stored in another table:
SELECT, p.product_name, c.description AS ‘cat_description’
FROM products p
INNER JOIN categories c on p.category_id =

Using a well designed relational database and JOINed queries will make your PHP code simpler and more efficient by returning the data from two or more tables in one query.

Like this post? please leave a comment below: