Excuse my total ignorance on the above subject. I am trying to access a mysql 
database via a perl script, and I came across the example below, but am not 
sure whether my are correctly filled (where marked ######################## 
below).
I would appreciate assistance to clarify what should actually go into those 
fileds.
Secondly when I run my script, it says $rv and $rc are used once.
Will appreciate
Zilore


print "Content-type: text/html\n\n";

## mysql user database name
$db ="IP address";         # should the IP address be here or I just put MySQL? 
########################
## mysql database user name
$user = "myuser";
 
## mysql database password
$pass = "mypass";
 
## user hostname : This should be "localhost" but it can be diffrent too
#$host="localhost";
$host="localhost";  # is this ok or should I put the IP address here? 
######################## 

## SQL query
$query = "show tables";
 
#$dbh = DBI->connect("DBI:mysql:$db:$host", $user, $pass);
$dbh = DBI->connect("DBI:mysql:$db:$host", $user, $pass);          # should it 
be DBI:mysql? or ? ########################
$sqlQuery  = $dbh->prepare($query) or die "Can't prepare $query: 
$dbh->errstr\n";
 
$rv = $sqlQuery->execute or die "can't execute the query: $sqlQuery->errstr";
 
print "<h3>********** My Perl DBI Test ***************</h3>";
print "<p>Here is a list of tables in the MySQL database $db.</p>";
while (@row= $sqlQuery->fetchrow_array()) {
my $tables = $row[0];
print "$tables\n<br>";
}
$rc = $sqlQuery->finish;
exit(0);
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to