List:General Discussion« Previous MessageNext Message »
From:Douglas Brantz Date:April 25 2000 4:42pm
Subject:DBI seems to work now
View as plain text  
Ok here is what I am using for DBI connect for mysql and it seems to
work ok.
If anyone can give me pointers on cleaning up this code I would
appreciate it very much.


Thanks

Douglas

#!/usr/bin/perl -w
#

#use strict;
use diagnostics;
use CGI;
use Mysql;
use DBI;

#Setup main program
my $query= new CGI;

#Print out a contect type for http/1.0 compatibility
print $query->header("text/html");

#Grab the values from the form
my $lab_title=$query->param("LABNAME");
#
#  open database on Linux
#
my $dbh =
DBI->connect("DBI:mysql:database:localhost","username","password");
if (not $dbh) {
print header start_html ('title'=>"Error Information");
print <<END_OF_HTML;
The connection attempt failed for the following reason:<br>
$DBI::errstr
</body></html>
END_OF_HTML
exit(0);
}

my $in=$dbh->prepare("Insert into
tablename(lab_title)values($lab_title)");

$in->execute;


#--------------------------------------------------------------
print<<END_OF_HTML;
<html>
<head>
<title>Lab Info</title>
</head>
<body>
<b>You have entered the following</b>
$lab_title
</body>
</html>
END_OF_HTML
exit;

--

Douglas Brantz
Computer Consultant
Fine & Applied Arts
Appalachian State University
Boone, NC 28608

828-262-6312 FAX
828-262-6549 OFFICE
brantzdr@stripped


Thread
DBI seems to work nowDouglas Brantz25 Apr