Advertisement
Advertisement
| 06.21.2008 at 07:47AM PDT, ID: 23504611 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: |
#!C:/bin/perl.exe -w
use DBI;
#definition of variables
$db="music";
$host="localhost";
$user="username";
$password="pass";
print "Content-type:text/html\n\n";
#connect to MySQL database
my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host",
$user,
$password)
or die "Can't connect to database: $DBI::errstr\n";
#prepare the query
my $sth = $dbh->prepare( "SELECT * FROM trackinfo");
#execute the query
$sth->execute( );
## Retrieve the results of a row of data and print
print "\tQuery results:\n================================================\n";
while ( my @row = $sth->fetchrow_array( ) ) {
print "@row\n";
}
warn "Problem in retrieving results", $sth->errstr( ), "\n"
if $sth->err( );
exit;
|