Solved

DBI & CGI

Posted on 2000-02-26
3
191 Views
Last Modified: 2013-12-25
where can I learn more about CGI.pl and DBI.pl (I think this is what they are called).
0
Comment
Question by:evildogeye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:monas
ID: 2561524
perldoc CGI

and

perldoc DBI

are command you want to issue...
0
 
LVL 10

Accepted Solution

by:
makerp earned 50 total points
ID: 2562376
if your running activeperl on win32 both modules are well docuemented in the help which youll find on start\activestate. i dont think that dbi comes with activestate but when you install it providing you use ppm the help files will be added.

as far as books go perl in a nutshell provides a chapter on both modules that contain some good examples and complete listings\descriptions on all functions belonging to these modules. perl in a nutshell is only about £14 so its well worth it.

dbi is really easy to use. all you have to do is get the dbi module and then get a dbd module for the database you want to use. dbi provides the interface and framework for vendor specific dbd drivers. the dbd actaully implements the methods which talk to the db.  

dbd modules can be obtained for most dbs from either cpan or activestate\packages\zips. for access use the odbc dbd module, this will work for sql server aswell.

use DBI;
#open the database
$db_handle->connect(dbi:<DBD DRIVER>:<DSN>,'username','password');
#prepare statment
$st_handle = $db_handle->prepare("Some sql ");
#execute it
$st_handle->execute();
#loop through displaying results
while($data = $st_handle->fetchrow_hashref())
{
   print("result : ".$data->{"the_field_name"});
}

see its easy !!. in the connect bit <DSN> is a dsn you have set up for you database, or the address of a db server such as oracle followed by the database name. and <DBD DRIVER> is the name of the dbd driver you want to use. note theres not a use DBD at the top.

some cgi pm

use CGI;
#create a cgi object
$query = new CGI;
#test if there any input parameters
if($query->param())
{
#get on
   $my_value_from_a_form = $query->param('form_value_name');
#print a header out
   print $query->header()
   print loads of html either using lots of print sttments or cgi functions

}                  
                 -
0
 
LVL 1

Expert Comment

by:stephenblade
ID: 2594585
Or actually you can read a step by step tutorial on the subject at:

http://perl.about.com/compute/perl/library/weekly/aa120699a.htm

0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

622 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