List:General Discussion« Previous MessageNext Message »
From:Douglas Brantz Date:April 25 2000 6:29pm
Subject:OK - I'm learning DBI Connect
View as plain text  
Now everything seems to be working much better:
Here is a sample of the code and please offer if any suggestions
to clean this up.

The only error I'm getting now when I run the file from the command line
Database handle destroyed without explicit disconnect, <STDIN> chunk 1.

My only source for help has been the O'REILLY Mysql & mSQL book.


#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 =
#-----Create the command---------------
my $command = "";
$command =<<"EOC";
insert into lab (lab_title) values ("$lab_title")
#---Uncomment for debugging-------------------
#print "<P>SQL command: \"$command\"</p>\n";
#--------Prepare the Command and Execute it---------------
my $sth = $dbh->prepare($command);

die "error with command \"$command\""
 unless (defined $sth);

<title>Lab Info</title>
<b>You have entered the following</b>


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

828-262-6312 FAX
828-262-6549 OFFICE

OK - I'm learning DBI ConnectDouglas Brantz25 Apr
  • RE: OK - I'm learning DBI Connectindrek siitan25 Apr
  • RE: OK - I'm learning DBI Connectbenjamin-weiss25 Apr
    • Re: OK - I'm learning DBI ConnectThimble Smith26 Apr