in reply to Knowing if an Operation is Successful in MySql
As for whether or not the row was actually inserted or not, i usually set up my database appropriately. You really should set up your cardbase table to use an auto incremented id as a primary key. That way, you don't insert the id yourself, and you won't have to worry about duplicates, which is usually the only reason why the row would not be insertable in the first place. Also note that i am not interpolating $id and $picture inside the SQL query string, but instead i am declaring them as placeholders and i pass the actual variables to execute() which will quote them for me. This is another potential spot where a query could fail.my $dbh = DBI->connect( "DBI:$driver:$database:$host", $user, $pass, {RaiseError => 1}, ); my $sth = $dbh->prepare(' INSERT INTO cardbase (id,picture) VALUES (?,?) '); my $result = $sth->execute($id,$picture); # etc.
Do yourself a big favor and read DBI recipes today. :)
UPDATE: and Use placeholders. For SECURITY! as well ...
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|