From the course: PHP for Web Designers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Connecting to the database

Connecting to the database - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

Connecting to the database

When connecting to mySQL with PHP, you need to be aware you have a choice of options. This page in the PHP documentation explains that PHP offers three different API's to connect to a MySQL database. MySQL, MySQLI, and PDO. If you're not familiar with the term API, it stands for application programing interface, and it simply means a set of functions. So which should you use? Well, the choice is made simpler by the fact that the old MySQL extension has been deprecated and will be removed from a future version of PHP, so it says down here it's recommended. To use either the MySQLI or the PDO_MySQL extensions. It's not recommended to use the old MySQL extension. The advantage of PDO is that it's designed to work with a wide range of database systems, so in theory at least. You could later switch from MySQL to Microsoft SQL server, however its not quite so straight forward because of subtle variations in the query language used by different database systems. The advantage of MySQLI is…

Contents