- Things we need to do before we continue our work:
Make sure you install the right DBI.
Perl DBI for Mysql : http://www.cs.wcupa.edu/docs/mysqlEZinfo/perl_dbi.html
Install Perl DBI : http://cpansearch.perl.org/src/RUDY/DBD-mysql-2.9008/INSTALL.html#windows
Without DBI, you may encounter eorrors like: "Can't locate mysql.pm in @INC....."
- Connect to Mysql and return value of data.
#!/usr/bin/perl use mysql; # HTTP HEADER print "Content-type: text/html \n\n"; # MYSQL CONFIG VARIABLES $host = "localhost"; $database = "test"; $tablename = "test_set"; $user = ""; $pw = ""; # PERL MYSQL CONNECT() $connect = Mysql->connect($host, $database); # SELECT DB $connect->selectdb($database); # DEFINE A MySQL QUERY $myquery = "SELECT * FROM $tablename"; # EXECUTE THE QUERY $execute = $connect->query($myquery); $rownumber = $execute->numrows(); $fieldnumber = $execute->numfields(); # PRINT THE RESULTS print "row:".$rownumber."\n"; print "col:".$fieldnumber."\n";