Script PHP is a scripting language that can write Web pages that contain embedded code that can be executed as long as the page is accessed, and the code can generate dynamic content to be sent to the client's Web browser as part of the output. This chapter describes how to write the application based on we b in PHP using MySQL. For a comparison of C with the PHP and Perl DBI APIs, see Chapter 5th, "MySQL Programming introduction."
Examples of this chapter take advantage of the sample database samp_db, which uses the tables created for the credits save scheme and the tables created for the History League in chapter 1th, "MySQL and SQL introduction." Although PHP 4 is still in the test phase while writing a book, and when you read this book it may have been published, but it still involves the contents of PHP 3. Compatibility with PHP 3 is a clear design goal for PHP 4, so all aspects of PHP 3 described here can be applied to PHP 4. Changing from PHP 3 to PHP 4 has a set of porting considerations. If you use PHP 4, you should read those comments.
This chapter assumes an environment in which PHP is used in conjunction with Apache server. You must install the MYSQLC client library and header files because you need these files when you build PHP, or PHP does not know how to access the MySQL database. If you need to obtain some of these software, see Appendix A, "Getting and installing software." The appendix also gives instructions for obtaining the instance scripts developed in this chapter, which you can download directly.
In a UNIX environment, PHP or as an builtin module is used for Apache, which is connected to Apache executable binaries, or as an independent interpreter for traditional CGI programs. In the Windows environment, while work is under way to develop the Apache PHP 4 module that runs in the Windows NT environment, PHP can only run as a stand-alone program at the moment.
Much of this chapter is used to illustrate the PHP functions that are needed to discuss here. To get a complete picture of all the MySQL-related functions, see appendix H, "PHP API Reference," or the PHP manual, which describes all the functions provided by PHP, including the use of a database other than MySQL (when using MySQL, The unrestricted part of PHP is only dbi. This manual can be downloaded from the PHP Web site: http://www.php.net/. The Web site also has considerations for porting from PHP 3 to PHP 4.
The file name of the PHP script has an extension that allows the Web server to recognize the file name and execute the PHP interpreter to handle them. If an unrecognized extension is used, the PHP script is treated as plain text. The extension used in this chapter is. P h p, and the other generic extensions are. php3 and. P h t M L. For instructions on configuring Apache to identify the extension, see Appendix A. On a machine, if you don't have an Apache installation, check with your system administrator to find the appropriate extension to use.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.