List:General Discussion« Previous MessageNext Message »
From:Jeremy Date:April 20 1999 3:48pm
View as plain text  
I'm very new to MySQL, CGI and Perl and this may not be
the best place to post my question, but I'm gonna try...

I have a small SQL database/table and I have been adding
records to it manually with the mysql client (INSERT INTO...).
In the past few minutes, I tried to whip up a perl script
so that I could do this from the web browser and save
myself some typing. I have everything (modules, etc) that
is needed installed.

I enter the data into the html form and hit the submit
button.  It takes a minute (this is a slow machine) and
the html that is supposed to be returned is displayed,
along with a new copy of the same form.  (The CGI outputs
the HTML for the form so I don't have to click 'Back').
However, the record never gets added to the table.  I
ran the CGI script manually...

[jeremy@jgaddis:tty3:/var/www/cgi-bin]$ ./
(offline mode: enter name=value pairs on standard input)
Content-type: text/html

<HTML><HEAD><TITLE>Add records to homeint:items SQL
DBD::mysql::st execute failed: You have an error in your SQL syntax near
' at line 1 at ./ line 40, <> chunk 1.
You have an error in your SQL syntax near ';
' at line 1 at ./ line 40, <> chunk 1.
Database handle destroyed without explicit disconnect, <> chunk 1.

The "id=11830&desc..." line is entered manually by me
then it starts returning the html.  It stops after the <BODY>
tag, until I press Enter.  That's when the error messages come

Here's the relevant lines from

my $sth = $dbh->prepare(q{
  insert into testtable values (?, ?, ?);
}) || die $dbh->errstr;

while (<>) {
  my ($id, $description, $cost) = split /,/;
  $sth->execute($id, $description, $cost) || die $dbh->errstr;

The second to last line ("$sth->execute...") is line 40,
which is supposed to have the error.  I've tried and
tried but I can't figure it out.  Anyone know what's
going on?

To automatically retrieve my PGP key via e-mail, send a
blank message with the subject line "fetch pgp key".

problems...Jeremy20 Apr
  • Re: problems...Christian Mack20 Apr
    • Re: problems...Paul DuBois20 Apr
    • Re: problems...Jeremy20 Apr
  • Re: problems...Sasha Pachev20 Apr