List:General Discussion« Previous MessageNext Message »
From:Douglas Brantz Date:April 25 2000 5:41pm
Subject:[Fwd: DBI seems to work now]-not really
View as plain text  
Well - seems that I am getting an error after all using the code below:
DBD::mysql::st execute failed: Unknown column 'testing' in 'field list' at
./lab
.pl line 25, <STDIN> chunk 1.
<html>
<head>
<title>Lab Info</title>
</head>
<body>
<b>You have entered the following</b>
testing
</body>
</html>
Database handle destroyed without explicit disconnect, <STDIN> chunk 1.

Basically I am not inserting the data properly into the table.


Douglas Brantz wrote:

> 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
>
> --
> ---------------------------------------------------------------------
> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
> posting. To request this thread, e-mail mysql-thread35188@stripped
>
> To unsubscribe, send a message to:
>     <mysql-unsubscribe-brantzdr=appstate.edu@stripped>

--

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

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


Thread
[Fwd: DBI seems to work now]-not reallyDouglas Brantz25 Apr