Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP & MySQL - Cannot get INSERT INTO to work correctly
    primarykey
    data
    text
    <p>I've been trying things for over an hour to get this to insert into my database correct. I can't figure this out for the life of me even though queries exactly like work just fine. </p> <p>No errors are being thrown on the page, but it is not inserting the data into the database. </p> <p>PHP Code (The variable are posting correctly to the page):</p> <pre><code>&lt;?php error_reporting(E_ALL); //start session session_start(); //include database connection include('../db_connect.php'); //import info $client = $_POST['client']; $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $phone = $_POST['phone']; $address1 = $_POST['address1']; $address2 = $_POST['address2']; $address3 = $_POST['address3']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $country = $_POST['country']; $vehicle = $_POST['vehicle']; $msrp = $_POST['msrp']; $saleprice = $_POST['saleprice']; $date = date("Y-m-d H:i:s"); $status = "Pending"; $notes = "Test notes are great!"; $sql = "INSERT INTO sales (salePrice, saleDate, saleStatus, saleNotes, saleName, saleCompany, salePhone, saleEmail, saleAddress1, saleAddress2, saleAddress3, saleCity, saleState, saleZipcode, saleCountry, clientFK) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; if ($stmt = $mysqli-&gt;prepare($sql)) { /* Bind our params */ $stmt-&gt;bind_param('dssssssssssssssi', $saleprice , $date , $status , $notes , $name , $company , $phone , $email , $address1 , $address2 , $address3 , $city , $state , $zip , $country , $client); /* Execute the prepared Statement */ $stmt-&gt;execute(); /* Echo results */ echo "Inserted user information into database.\n"; /* Close the statement */ $stmt-&gt;close(); }else{ /* Error */ printf("Prepared Statement Error: %s\n", $mysqli-&gt;error); } ?&gt; </code></pre> <p>Here is the layout of this table in my database:</p> <pre><code>CREATE TABLE IF NOT EXISTS `sales` ( `idsale` int(11) NOT NULL AUTO_INCREMENT, `salePrice` double NOT NULL, `saleDate` datetime NOT NULL, `saleStatus` varchar(50) NOT NULL, `saleNotes` varchar(100) DEFAULT NULL, `saleName` varchar(70) DEFAULT NULL, `saleCompany` varchar(50) DEFAULT NULL, `salePhone` varchar(20) DEFAULT NULL, `saleEmail` varchar(255) DEFAULT NULL, `saleAddress1` varchar(35) DEFAULT NULL, `saleAddress2` varchar(35) DEFAULT NULL, `saleAddress3` varchar(35) DEFAULT NULL, `saleCity` varchar(20) DEFAULT NULL, `saleState` varchar(50) DEFAULT NULL, `saleZipcode` varchar(15) DEFAULT NULL, `saleCountry` varchar(50) DEFAULT NULL, `createdBy` varchar(30) DEFAULT NULL, `createdDate` datetime DEFAULT NULL, `modifiedBy` varchar(30) DEFAULT NULL, `modifiedDate` datetime DEFAULT NULL, `clientFK` int(11) NOT NULL, PRIMARY KEY (`idsale`), KEY `clientFK_INDEX` (`clientFK`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; </code></pre> <p>Any help will be appreciated! Thanks for your help ahead of time. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload