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 - PHP Tutorial
From the course: PHP for Web Designers
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Loading data into MySQL5m 37s
-
(Locked)
Connecting to the database7m 47s
-
Querying the database6m 15s
-
(Locked)
Displaying the results of the query3m 50s
-
(Locked)
Using modulo division to establish a repeating series4m 20s
-
(Locked)
Repeating output at specific intervals in a loop4m 56s
-
(Locked)
Linking to a details page2m 40s
-
(Locked)
Embedding a variable in a query securely6m 5s
-
(Locked)
Handling database errors gracefully--and securely8m 40s
-
(Locked)
-
-