Gossamer Forum
Home : General : Databases and SQL :

My INSERT Statement appends blank record, why??

Quote Reply
My INSERT Statement appends blank record, why??
Ive got this following cgi code and it dont wanna seem to work, it inserts a blank record into the MySQL database, the ID field is an auto number field



my $dbh = DBI->connect($dsn, $username, $password);

my $sql_appendstatement = "INSERT INTO `TournamentDates` (`ID`, `Course`, `CourseLoc`, `CompType`, `CompDay`, `CompDate`, `TeeOff`, `Finished`, `Order`) VALUES ('', '$FORM{Coursenew}', '$FORM{Locationnew}', '$FORM{Typenew}', '$FORM{Daynew}', '$FORM{Datenew}', '$FORM{TeeOffnew}', '0', '$FORM{Ordernew}')";


my $sth = $dbh->prepare($sql_appendstatement) || die "Could not prepare: " . $dbh->errstr();


$sth->execute() || die "Could not execute: " . $dbh->errstr();
$sth->finish();
$dbh->disconnect();

All the $FORM{*} values contain values cause ive put a print statement after it runs the sql statement with the value of the sql string and it printed out.



INSERT INTO `TournamentDates` (`ID`, `Course`, `CourseLoc`, `CompType`, `CompDay`, `CompDate`, `TeeOff`, `Finished`, `Order`) VALUES ('', '5555555', '5576g7657657', '5g7765765', '76yf', '5765757567', 'fhfgfg', '0', '1')



Whats wrong with that?? why wont it work right? ive copy and pasted the above sql string into myphpadmin and executed it and it appends the record fine, but it wont append it from my script. well it appends it but its blank. ??
Subject Author Views Date
Thread My INSERT Statement appends blank record, why?? TheIceman 8941 Nov 1, 2002, 6:51 PM
Thread Re: [TheIceman] My INSERT Statement appends blank record, why??
cornball 8621 Nov 1, 2002, 8:19 PM
Thread Re: [cornball] My INSERT Statement appends blank record, why??
TheIceman 8637 Nov 2, 2002, 4:55 AM
Thread Re: [TheIceman] My INSERT Statement appends blank record, why??
cornball 8608 Nov 2, 2002, 8:01 AM
Post Re: [cornball] My INSERT Statement appends blank record, why??
TheIceman 8549 Nov 2, 2002, 8:20 PM
Thread Re: [TheIceman] My INSERT Statement appends blank record, why??
dearnet 8535 Nov 6, 2002, 11:34 PM
Post Re: [rajani] My INSERT Statement appends blank record, why??
Paul 8446 Nov 7, 2002, 2:23 AM