Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL query fails on integrity constraint violation
    primarykey
    data
    text
    <p>This query keeps failing with</p> <blockquote> <p>Integrity constraint violation: 1048 Column 'login_name' cannot be null</p> </blockquote> <p>My insert statement is...</p> <pre><code> $insertUserQuery = 'INSERT INTO `users` ( `login_name`, `password`, `first_name`, `last_name`, `company_name`, `company_address`, `country`, `email`, `phone_number`, `agency_type`, `sold_before`, `authorised`, `current_module` ) VALUES ( :login_name, :login_password, :first_name, :last_name, :company_name, :company_address, :country, :email, :phone_number, :agency_type, :sold_before, 0, 0);'; $bindings = array(':login_name' =&gt; $loginName, ':login_password' =&gt; sha1($password . Config::PASSWORD_SALT), ':first_name' =&gt; $firstName, ':last_name' =&gt; $lastName, ':company_name' =&gt; $companyName, ':company_address' =&gt; $companyAddress, ':country' =&gt; $country, ':email' =&gt; $emailAddress, ':phone_number' =&gt; $phone, ':agency_type' =&gt; null, ':sold_before' =&gt; null ); print_r($bindings); Db::query($insertUserQuery, $bindings); </code></pre> <p>My database class can be found <a href="https://stackoverflow.com/questions/617646/is-this-wrapper-for-pdo-good-code-are-there-any-potential-problems">at another question</a>. The <code>print_r()</code> tells me that the array definitely has a value. </p> <p>May it have something to do with me using the word 'password' which is also a MySQL function?</p> <p>Does PDO support prepared statements with INSERT in the same fashion as it does with SELECT?</p> <p>Do I need to quote around the values, example ':login_name'?</p>
    singulars
    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.
 

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