Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
the below code is giving following error: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 at /var/www/cgi-bin/tt.cgi line 35.
#!/usr/bin/perl use warnings FATAL => 'all'; use CGI; use CGI::Carp qw(fatalsToBrowser); use DBI; use DBD::mysql; my $cgi = CGI->new; print $cgi->header, $cgi->start_html; my $title = $cgi->param('TITLE'); my $feature = $cgi->param('FEATURE'); my $type = $cgi->param('TYPE'); my $description = $cgi->param('DESCRIPTION'); my $status = $cgi->param('STATUS'); my $path = $cgi->param('PATH'); my $priority = $cgi->param('priority'); my $database = "test_case"; my $host = "localhost"; my $user = "chiragk"; my $pw = ""; my $dsn = "dbi:mysql:$database:localhost"; my $dbh = DBI->connect($dsn, $user, $pw, { RaiseError => 1 }) or die "una +ble to connect:$DBI::errstr\n"; my $query = "insert into test(title,feature_name,type,description, +status,test_case_path,priority) values(?,?,?,?,?,?,?,)"; my $sth = $dbh->prepare($query); $sth->execute("$title","$feature","$type","$description","$status" +,"$path","$priority"); print $cgi->p("[$title],[$feature],[$type],[$description],[$status +],[$path],[$priority]"); print $cgi->end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBD::mysql::st execute failed: You have an error in your SQL syntax;
by Corion (Patriarch) on Jun 22, 2016 at 12:04 UTC | |
|
Re: DBD::mysql::st execute failed: You have an error in your SQL syntax;
by perlfan (Parson) on Jun 22, 2016 at 13:07 UTC | |
|
Re: DBD::mysql::st execute failed: You have an error in your SQL syntax;
by OpenSpace (Novice) on Jun 22, 2016 at 15:09 UTC | |
by perlfan (Parson) on Jun 22, 2016 at 18:15 UTC |