5.2. PHP Functions That Communicate with MySQL

PHP provides two sets of functions for communicating with MySQL — the mysql functions and the mysqli (MySQL Improved) functions. Which functions you use depends on the version of MySQL and PHP you're using.

The mysqli functions were added in PHP 5 for use with MySQL versions 4.1 and later. If you're using a Web hosting company, you need to know whether it offers PHP 5, which version of MySQL it provides, and whether it makes the mysqli functions available. In this book, we assume that you're using PHP 5 or 6, MySQL 5.0, and the mysqli functions. If your Web host doesn't offer the mysqli functions, you need to convert the mysqli functions in this book to mysql functions. The section "Converting mysqli Functions to mysql Functions," later in this chapter, explains the differences.

If you installed PHP and MySQL yourself on your own computer planning to develop your PHP scripts locally and upload the finished scripts to your Web hosting company, you need to install the same versions and activate the same MySQL support functions that your Web host provides. Otherwise, if you install different versions, even newer ones, the scripts may not behave in the same way on your Web host's computer as they do on your local computer.

You can find a discussion of the issues about and instructions for installing your Web development environment in Book I.

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.