Okay, let's get back to PHP, and look at how you can tap into all this database power from your dynamic Web pages.
If you're feeling a little overwhelmed after going through all those SQL statements, don't worry! It's not essential that you understand every last detail at this stage. You just want to get an overall feel for how you go about interacting with a relational database such as MySQL. You'll become a lot more familiar with the specifics as you move on and start building applications for yourself.
Just as you used client programs to access the MySQL database server from the command line, PHP needs some client code of its own to talk to MySQL.
In the days of PHP4, this was a no-brainer because the necessary code was integrated right into the depths of PHP itself. Unfortunately that's no longer the case, and PHP5 expects the MySQL client libraries to be present on your system before compiling with PHP support. This is quite easy for Linux users: just ensure that you compile PHP5 using the -with-mysql option.
For Windows users, it's a little more complex. You need to:
- Ensure that the libmysql.dll library is in your system root path (libmysqli for versions of MySQL 4.1 and later).
- Uncomment the mysql extension in the extensions section of your php.ini file.
- Ensure that your php_mysql.dll extension is in a folder where PHP can find it. (This is set in the extension directory setting in the php.ini file.)
- Restart your Web server after you've implemented these changes.
That's it! Nothing too complicated—it's just like using any other extension in PHP. With everything set up, let's look at what you need to do to get PHP5 and MySQL talking to each other.
