List:General Discussion« Previous MessageNext Message »
From:Sasha Pachev Date:April 20 1999 3:56pm
Subject:Re: problems...
View as plain text  
Jeremy wrote:
> 
> 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]$ ./add2sqldb.pl
> (offline mode: enter name=value pairs on standard input)
> id=11830&description=Coronado+Shelf&cost=13.80
> Content-type: text/html
> 
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> <HTML><HEAD><TITLE>Add records to homeint:items SQL
> database</TITLE>
> </HEAD><BODY>
> DBD::mysql::st execute failed: You have an error in your SQL syntax near
> ';
> ' at line 1 at ./add2sqldb.pl line 40, <> chunk 1.
> You have an error in your SQL syntax near ';
> ' at line 1 at ./add2sqldb.pl 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
> up.
> 
> Here's the relevant lines from add2sqldb.pl...
> 
> my $sth = $dbh->prepare(q{
>   insert into testtable values (?, ?, ?);
> }) || die $dbh->errstr;
> 
> while (<>) {
>   chop;
>   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?
> 
> TIA,
> Jeremy

Make your code actually print the query it is trying to
run, or check your mysql log to see what query you are 
doing.


-- 
Sasha Pachev
http://www.sashanet.com/ (home)
http://www.direct1.com/ (work)
Thread
problems...Jeremy20 Apr
  • Re: problems...Christian Mack20 Apr
    • Re: problems...Paul DuBois20 Apr
    • Re: problems...Jeremy20 Apr
  • Re: problems...Sasha Pachev20 Apr