title: PHP, Error 1136 : Column count doesn't match value count at row 1
body: <p>I get this Exception:</p>
  
  <pre><code>Error 1136 : Column count doesn't match value count at row 1
  </code></pre>
  
  <p>Structure of the table :</p>
  
  <pre><code>create table gb_entries (
      id int(4) not null auto_increment,
      username varchar(40) not null,
      name varchar(40),
      gender varchar(40),
      dob int(40),
      email varchar(40),
      primary key (id) 
  );
  </code></pre>
  
  <p>With this PHP code:</p>
  
  <pre><code>// Add a new entry to the database
  function addEntry($username, $name, $gender, $dob, $email) {
    $connection = mysql_open();
    $insert = "insert into gb_entries " . 
        "values ('$username', '$name', '$gender', '$dob', '$email')";
    $result = @ mysql_query ($insert, $connection)
        or showerror();
    mysql_close($connection)
        or showerror();
  }
  
  // Return an array of database entries that contain $name anad $email
  function getEntries($username,$name,$gender,$dob,$email) {
    // Sanitise user input to prevent SQL injection attacks
    $username = mysql_escape_string($username);
    $name = mysql_escape_string($name);
    $gender = mysql_escape_string($gender);
    $dob = mysql_escape_string($dob);
    $email = mysql_escape_string($email);
  
  
    // Open connection and select database
    $connection = mysql_open();
  
    // Construct query
    $query = 
      "select username, name, gender, dob, email from gb_entries where 0=0 ";
    if (! empty($username)) {
        $query .= "AND username LIKE '%$username%' ";
    }
     if (! empty($name)) {
        $query .= "AND name LIKE '%$name%' ";
    }
    if (! empty($gender)) {
        $query .= "AND gender LIKE '%$gender%' ";
    }
    if (! empty($dob)) {
        $query .= "AND dob LIKE '%$dob%' ";
    }
    if (! empty($email)) {
        $query .= "AND email LIKE '%$email%' ";
    }
  
  
    $query .= "ORDER BY id";
    // echo $query;
  
    // Execute query
    $result = @ mysql_query($query, $connection)
        or showerror();
  
    // Transform the result set to an array (for Smarty)
    $entries = array();
    while ($row = mysql_fetch_array($result)) {
        $entries[] = $row;
    }
  
    mysql_close($connection)
        or showerror();
    return $entries;
  }
  </code></pre>
  
  <p>What does the Exception mean?</p>