Solved

CGI script to access database info and email it.

Posted on 2002-06-03
4
155 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:CUTTHEMUSIC
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:samri
Comment Utility
What OS and Webserver platform are you running anyway?  What is your Perl version?

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:RESKIT', 'user', 'password');

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.
0
 
LVL 15

Accepted Solution

by:
samri earned 200 total points
Comment Utility
What OS and Webserver platform are you running anyway?  What is your Perl version?

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:RESKIT', 'user', 'password');

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.
0
 
LVL 12

Expert Comment

by:lexxwern
Comment Utility
#!/usr/local/bin/perl -w

use DBI;
use warnings;


$dbh =
     DBI->connect ("DBI:mysql:database=...;host=...;port=...",$DBuser,$DBpass)
          or
     die $DBI::errstr;


$query = "select * ...";
$askquery = $dbh->prepare($query);

$getentry = $askquery->execute;




this is how to work with DBI..
0
 
LVL 12

Expert Comment

by:lexxwern
Comment Utility
CUTTHEMUSIC, are you here?
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now