Database access with the Perl DBI::DBD modules
Posted: Mon Jun 10, 2002 2:09 pm
I'm currently in the process of changing servers and this is the first time I've come across Mysql being set-up off the same server. The company I'm with used Perl to talk back and forth and frankly I have no perl experience. They are suggesting using the following code but when I place it inside my <?php ?> tags it give me a parse error. Can some help me by explaining how this works???
#!/usr/bin/perl
use DBI;
$dsn = "DBI:mysql:database=databasename";
$dbh=DBI->connect($dsn, "username", "password");
$sth = $dbh->prepare("SELECT * FROM table where ID=''5'' ORDER BY date");
$sth->execute;
while( (@results = $sth->fetchrow) != NULL) {
if ($results[2] > 500) {
print "$results[0] - $results[1] - $results[2] - $results[4] - $results[6]\n";
}
}
Thank you in advance...
#!/usr/bin/perl
use DBI;
$dsn = "DBI:mysql:database=databasename";
$dbh=DBI->connect($dsn, "username", "password");
$sth = $dbh->prepare("SELECT * FROM table where ID=''5'' ORDER BY date");
$sth->execute;
while( (@results = $sth->fetchrow) != NULL) {
if ($results[2] > 500) {
print "$results[0] - $results[1] - $results[2] - $results[4] - $results[6]\n";
}
}
Thank you in advance...