Database Reference
In-Depth Information
do {
$row = mysql_fetch_row($myResults);
print “<TR><TD>$row[0]</TD><TD>$row[1]</TD><TD>$row[2]</TD></TR>”;}
while ($row);
print “</TABLE>”;
mysql_free_result($resultsSet);
mysql_close($myConnection);
?>
</BODY>
</HTML>
I have put a little error trapping in the script so that if you want to try a few different
queries you can do so and get some feedback if there are any problems. This script can be
seen running in Figure 15.7.
Working with Perl
Perl is an interpreted programming language that you can use to write CGI scripts. Like
some of the other applications we have just discussed, Perl accesses databases through a set
of driver functions that are known as DBI (Database Interface). Perl scripts reside in a cgi-
bin directory of your webserver, so in our example installation ours are stored at:
C:\indigoperl\apache\cgi-bin
Figure 15.6 has already shown one of the scripts in this directory running when we
pointed the browser at:
http://localhost/cgi-bin/mysqlsamp2.pl
Figure 15.7
The working PHP script.
Search WWH ::




Custom Search