Chapter 5

Connecting PHP to a MySQL Database

In This Chapter

arrow Building the connection string

arrow Sending queries to a database

arrow Retrieving data results

arrow Formatting data output

arrow Allowing user queries

arrow Cleaning user-submitted data requests

Data has become the prominent feature of the web. As you build more sophisticated sites using HTML and CSS, you will eventually feel the need to incorporate data into your websites. You can do a certain amount of data work with the basic data structures built into PHP, but more sophisticated data problems require more sophisticated tools. Likewise, MySQL is great at data, but is not perfect for getting input from users or preparing HTML output. PHP and MySQL are perfect partners, with very compatible strengths and weaknesses.

tip.eps This chapter assumes you have a ...

Get HTML5 and CSS3 All-in-One For Dummies, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.