troubleshooting Question

Why does SQLite insert two records?

Avatar of curiouswebster
curiouswebsterFlag for United States of America asked on
Web DevelopmentPHPWeb Languages and StandardsScripting LanguagesWordPress
2 Comments2 Solutions12 ViewsLast Modified:
Here is my code:
$smt = $db->prepare("insert into  contacts (statusid, fname, lname, street, city, state, zip, title, company, voterid, campaign, create_date, update_date) values (:statusid, :fname, :lname, :street, :city, :state, :zip, :title, :company, :voterid, :campaign, :create_date, :update_date)");
$smt->bindValue(':statusid', 5, SQLITE3_INTEGER); // statusId of 5 == "Pending"
$smt->bindValue(':fname', $_GET['fname'], SQLITE3_TEXT);
$smt->bindValue(':lname', $_GET['lname'], SQLITE3_TEXT);
$smt->bindValue(':street', $_GET['street'], SQLITE3_TEXT);
$smt->bindValue(':city', $_GET['city'], SQLITE3_TEXT);
$smt->bindValue(':state', $_GET['state'], SQLITE3_TEXT);
$smt->bindValue(':zip', $_GET['zip'], SQLITE3_TEXT);
$smt->bindValue(':title', $_GET['title'], SQLITE3_TEXT);
$smt->bindValue(':company', $_GET['company'], SQLITE3_TEXT);
$smt->bindValue(':voterid', $_GET['vid'], SQLITE3_TEXT);
$smt->bindValue(':campaign', $_GET['cc'], SQLITE3_TEXT);
$smt->bindValue(':create_date', date("Y-m-d h:i:s"), SQLITE3_TEXT);
$smt->bindValue(':update_date', date("Y-m-d h:i:s"), SQLITE3_TEXT);

$result = $smt->execute();
var_dump($result->fetchArray(SQLITE3_ASSOC));
$smt->close();
$db->close();
$db=null;

This inserts two records.

When I remove $smt->execute(); there are no records added.

Could the browser be sending two requests on Enter?
SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros