Home : General : Databases and SQL :

General: Databases and SQL: Re: [TheIceman] My INSERT Statement appends blank record, why??: Edit Log

Here is the list of edits for this post
Re: [TheIceman] My INSERT Statement appends blank record, why??
Hello!

Try the following by wrapping your my statement with a pipe:



my $sql_appendstatement = qq|"INSERT INTO `TournamentDates` VALUES ('', '$FORM{Coursenew}', '$FORM{Locationnew}', '$FORM{Typenew}', '$FORM{Daynew}', '$FORM{Datenew}', '$FORM{TeeOffnew}', '0', '$FORM{Ordernew}')"|;


Instead of `TournamentDates` you could also use simply TournamentDates

Also in the my statement you could simply use ? instead of '$FORM{Daynew}' and then later in the prepare use the entire line inbetween ( and )! So it would look like :

my $sth = qq|"INSERT INTO TournamentDates VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"|;

$sth->execute("", $FORM{Coursenew}, $FORM{Locationnew}, $FORM{Typenew}, $FORM{Daynew}, $FORM{Datenew}, $FORM{TeeOffnew}, "0", $FORM{Ordernew}) || die "Could not execute: " . $dbh->errstr();

Now if you want to find if there is any problem with the $Form values, there is nothing to prevent you in making the INSERT only a fixed value like "please or "solve" or "my" or "problem" instead of $FORM{value}! Here there is no value to be given as an output to the INSERT statement.

Also this problem implies that your insert statement did not have any value and therefore it could not insert of because the number of the columns where not matching the insert matrix.

INSERT will be executed IF AND ONLY IF the insert format, in your case nine columns, is equal to the table column fields if they are nine. Otherwise there will be simply a mysql_insertid generated and the fields will not be inserted.

You could also use in place of the autoincrementfield "NULL" for it not to insert anything but increase the number forcefully.

Last edited by:

rajani: Nov 6, 2002, 11:39 PM

Edit Log: