我无法解决这个错误"专栏' Nume_elev'不能为空"

时间:2016-04-15 16:04:19

标签: php mysql

Table here... 在主演了大约2个小时之后,我无法找到问题。这是输出:......哦,所以需要发布更多的细节忽略这个东西正是我想要的......

This is the output

if(empty($data_missing)){
    require_once('./mysqli_connect.php');

    $stmt = mysqli_prepare($dbc,"INSERT INTO elev( Nume_elev, Nume_Parinte, Numar_tel, Numar_Tel_P, ADRESA, elev_id) VALUES( ?, ?, ?, ?, ?, NULL)");
    if($stmt === FALSE){ die(mysqli_error($dbc)); }
   mysqli_stmt_bind_param($stmt,"sssss", $Nume_elev, $Nume_Parinte, $Numar_tel, $Numar_Tel_P, $ADRESA);

  mysqli_stmt_execute($stmt);

    $affected_rows = mysqli_stmt_affected_rows($stmt);

    if($affected_rows == 1){

        echo 'Student Entered';

        mysqli_stmt_close($stmt);

        mysqli_close($dbc);

    } else {

        echo 'Error Occurred<br />';
        echo mysqli_error($dbc);
       mysqli_report(MYSQLI_REPORT_ERROR);
        mysqli_stmt_close($stmt);

        mysqli_close($dbc);

    }

} else {

    echo 'You need to enter the following data<br />';

    foreach($data_missing as $missing){

        echo "$missing<br />";

    }

}

}

?>

1 个答案:

答案 0 :(得分:1)

不要将NULL值用于自动增量列

$stmt = mysqli_prepare($dbc,"INSERT INTO elev( Nume_elev, Nume_Parinte, Numar_tel, Numar_Tel_P, ADRESA) 
VALUES( ?, ?, ?, ?, ?)");

mysqli_stmt_bind_param($stmt,"sssss", $Nume_elev, $Nume_Parinte, $Numar_tel, $Numar_Tel_P, $ADRESA);

同时检查$ Nume_elev的值。因为你在数据库中声明Nume_elev列不是null,所以它不会接受NULL或者&#39;&#39;将数据插入数据库时​​的值。

请确定哪些列值为NULL并相应地在数据库表中进行更改。