Mysqli Error: Column count doesn't match value

2019-07-27 05:50发布

问题:

Below is the mysqli query that is being performed, anyone know what I get such error:

$sql = mysqli_query($db, "INSERT INTO `tbl_bugzilla` 
    (`id`, `by`, `title`, `content`, `date`, `application`,`priority`, `assigned`, `status`) 
    VALUES (NULL, '".$_SESSION['exp_user']['username']."', '"
        .$_SESSION['exp_user']['username']."', '".$title."', '".$content."','"
        .$dt."', '".$_POST['app']."', '".$_POST['priority']."', 'Unassigned', 'Unconfirmed')");

Error: Column count doesn't match value count at row 1

More importantly, could you explain the error so I don't make the same mistake again?

Thanks

回答1:

Got the darn thing:

I mentioned '".$_SESSION['exp_user']['username']."', twice in the query, leading to 10 columns, not 9.

Sorry folks :(



标签: php mysqli