CUTTHEMUSIC
asked on
CGI script to access database info and email it.
I would like a CGI/Perl script that will pull data from a Access 2000 database and then create a text file and insert the data into it. Then the script will email the text file as an attatchment it to me. I have done this ASP already but would like to experiment with CGI. I have almost no experience with CGI/Perl
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
#!/usr/local/bin/perl -w
use DBI;
use warnings;
$dbh =
DBI->connect ("DBI:mysql:database=...;h ost=...;po rt=...",$D Buser,$DBp ass)
or
die $DBI::errstr;
$query = "select * ...";
$askquery = $dbh->prepare($query);
$getentry = $askquery->execute;
this is how to work with DBI..
use DBI;
use warnings;
$dbh =
DBI->connect ("DBI:mysql:database=...;h
or
die $DBI::errstr;
$query = "select * ...";
$askquery = $dbh->prepare($query);
$getentry = $askquery->execute;
this is how to work with DBI..
CUTTHEMUSIC, are you here?
To do such, you will need to;
1. Grab a copy of DBD::ODBC and DBI Perl module and have it installed on your system.
2. Configure ODBC Driver configured to the specified Access database that you need to connect to.
3. Next get your CGI code. Make sure you had you CGI.pm module installed to enable the output to be "web-enabled"
--- sample code that will list all tables in some database. Make sure you configure the ODBC connector to connect to that specified Acess Database.
---
#!c:\perl\bin\perl
use DBI;
$dbh = DBI->connect('dbi:ODBC:RES
my @dbs = $dbh->tables();
foreach (@dbs) {
print "== $_\n";
}
----------------
To see the usage of DBI modules, do a "perldoc DBI" from command prompt, it should give you the detailed description and some sample code that you could use.
good luck.