424 Part IV . (Personal web server) Development Figure 15-39: The

424 Part IV . Development Figure 15-39: The quote() method serves to make strings SQL safe. Building Basic Applications I ve been making basic applications throughout this chapter inside examples of error messages, queries, and updates. This section expands on some of those examples to show a basic Perl-based DBI application that uses functions and methods discussed in the previous section. The goal is to prepare you for building the applications needed to manage an e-commerce Web site in a later section. MySQL User Manager An earlier example created a small application to look at the hosts from which a given user is allowed to connect. I ll expand on that example here, making a more powerful user manager to examine the privileges that a given user/host combination has. As a starting point, Figure 15-40 illustrates the earlier program. This program, though fine for the examples, is woefully inadequate when it comes to error checking. For example, if the host field is blank, the program evaluates the while loop as false and stops iterating through it. Further, no input validation is done. I ve made changes to the program to make it check for errors and continue through the while loop even if the host is blank. I m doing some shenanigans on the actual query to make sure that it always returns something regardless of whether the hostis blank. I added the user to the query results so as to make it always evaluate true for the while loop. The program is shown in Figure 15-41.
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply