Where You're Going
In the third week, you'll complete your study of MySQL. You'll learn about the administrator tasks of a
MySQL database. Again, this week builds on your existing knowledge, taking you further down the road to
becoming a true MySQL DBA.
After you complete this week's training, you should have a thorough understanding of MySQL. Day 15
starts off the week by finishing up the last of the interfaces with "MySQL and PHP." On Day 16, you'll
learn how MySQL supports time. Day 17, "MySQL Database Security," covers all the aspects of
securing your database. On Day 18, you'll learn how MySQL compares to other relational database in
the market. Day 19 covers MySQL's administrative tasks. You'll learn what you can do to get the most
out of your MySQL database server on Day 20, "Optimizing MySQL." Finally, on Day 21, "Putting it All
Together," you'll cover the entire development process of a Web site that uses MySQL to create pages
dynamically and store information from the user.
Day 15: MySQL and PHP
Overview
This chapter will introduce you to PHP, a server-side scripting language that can be embedded into HTML
files.
Today, you will learn
PHP's principles of operation
How to embed PHP within HTML files on a Web server
How to use PHP as a front-end to a MySQL database
What Is PHP?
PHP stands for PHP: Hypertext Preprocessor. It is a language that has come out of the open source stable.
Fast growing in popularity, it is a competitor to Perl, ASP, JSP, and numerous other server-side scripting
solutions.
Server-Side Scripting
A Web server that contains nothing but HTML and graphics files might run a cosmetically good Web site.
The site might hold files with client-side scripts, such as JavaScript, DHTML, and Java to make the Web site
more dynamic. Nevertheless, an important interactive component will still be missing.
No matter how clever you get designing your HTML pages and writing your client-side code, there will
always be some aspects of interactivity that cannot be achieved. Communication with the user will still
be primarily one way: from server to client.
With a truly dynamic Web site, you overcome this limitation; You can allow users to interact with a vast
database, let them browse online stores, book a plane ticket online, and so on. For such scenarios, you
need code that is server-side executable.
That's where CGIs (Common Gateway Interfaces) come in. These are server-side executable
programs, in which the lines of program code are being run on the server rather than the client.
This has a number of advantages. CGIs allow interaction with large, online databases. They allow for
the two-way passing of information between client and server.
Another advantage is that the code is usually client-independent. While client-side code often needs to
be modified—even written twice—to cope with the differences between Netscape and Internet Explorer
and the different versions of these browsers, CGIs run on a single machine—the server. Being
independent of the client platform, you minimize development costs and ensure that the maximum
number of clients can use your site.