disconnecting when she’s finished. Using MySQL from a PHP script is conceptually similar to using it through the MySQL monitor. The key difference is that you don’t type queries into an interface but instead use PHP library functions to carryout actions such as connecting
to the database server, choosing a database, running a query, and retrieving the results. We show you an example later in this chapter.
The Apache Web ServerThe LAMP platform includes the Apache web server. While it isn’t necessary to use
Apache—PHP and MySQL can be used with other web servers—it’s our server of choice in this book. There are several reasons for this it’s free in a monetary and open source sense, it’s the
most popular server on the Web, it’s robust and scalable, it is the web server most commonly used with PHP, and it
works on all popular platforms,
including Linux, Windows, and Mac OS X. This section briefly explains web servers and Apache. We discussed how to configure Apache in Chapter Web servers are also known as HTTP servers. This describes their function a web browser or other web client makes a request fora web resource to a web server using the HTTP protocol the web server then serves this request and sends an HTTP response to the browser. There are essentially two classes of request that web servers can handle:
first, requests for static resources, such as HTML, XML,
or PDF documents, and, second, requests to run a script—often with parameters provided by the browser request
—and return the output in a response. The latter class is central to web database applications.
Web browsers send textual requests to web servers. An HTTP request is a text description of a required resource. For example, the following is what the Lynx browser sends
as a request for the resource http://www.invyhome.com/artist.php on the web server:
GET /artist.php HTTP/1.0
Host: www.invyhome.com
Accept: text/html, text/plain, audio/mod, image, video, video/mpeg,
application/pgp, application/pgp, application/pdf, message/partial,
message/external-body, application/postscript, x-be2,
application/andrew-inset, text/richtext, text/enriched
Accept: x-sun-attachment, audio-file,
postscript-file, default, mail-file,
sun-deskset-message, application/x-metamail-patch, application/msword,
text/sgml, */*;q=0.01
Accept-Encoding: gzip, compress
Accept-Language: en
User-Agent: Lynx/2.8.4dev.16 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6
The request lists all information required
to serve the request a method to use (
GET
),
the required resource, the HTTP version,
the host server, and details of the browser and what types of responses it can receive.
Share with your friends: