title: MySql: Insert values in an auto_increment field with PHP
body: <p>What I'm actually trying to do is insert a row with:</p>
  
  <blockquote>
    <p>INSERT INTO users VALUES (col1, col2, ...)</p>
  </blockquote>
  
  <p>where col1 is an auto_increment.</p>
  
  <p>The PHP code is:</p>
  
  <pre><code>&lt;?php 
  $host = "http://name.altervista.org/";
  $user = "name";
  $psw = "";
  $db = "my_name";
  
  $response = array();
  $response["success"] = true;
  
  $connessione = new mysqli($host, $user, $psw, $db);
  
  if($connessione-&gt;connect_errno == 0)
  {
      $nome = $_POST["nome"];
      $cognome = $_POST["cognome"];
      $username = $_POST["username"];
      $password = $_POST["password"];
      $nTelefono = $_POST["nTelefono"];
      $email = $_POST["email"];
  
      $sql = "INSERT INTO users 
              VALUES (DEFAULT, '$nome', '$cognome', '$username', '$password', '$nTelefono', '$email')";
      $ris = $connessione-&gt;query($sql);
  
      if($connessione-&gt;affected_rows == 1)
      {
          echo(json_encode($response)); 
      }
      else
      {
          $response["success"] = false;
          echo(json_encode($response)); 
      }
  }
  else
  {
      $response["success"] = false;
      echo(json_encode($response)); 
  }
  ?&gt;
  </code></pre>
  
  <p>I search similar questions here in stackoverflow, and I try to use DEFAULT or NULL, but it doesn't work. And if I put a number instead of the default value that is not already in the table it works, so I really don't understand where the problem is.</p>
  
  <p>Have you any other suggestions?</p>
  
  <p>EDIT: The table structure on the database:
  <a href="https://i.stack.imgur.com/SwtLI.png" rel="nofollow noreferrer">click</a></p>
  
  <p>EDIT 2: I tried to delete the table and create it again, and now it works with the NULL thing. Thanks for the support! </p>