curiouswebster
asked on
Why does SQLite insert two records?
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?
$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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.