MySQLi插入不正常

时间:2016-07-09 22:25:07

标签: php mysqli

if(isset($_POST['submit']))
{
    extract($_POST);

    $query = "INSERT INTO Messages VALUES(null,'$user_id','$subject','$msg')";
    mysqli_query($conn,$query) or die (mysqli_error($conn));
}

1 个答案:

答案 0 :(得分:0)

您可以尝试此代码(检查$ _POST先不是空的然后执行):

if ( !empty($_POST['submit'])) {
    $query = "INSERT INTO"
        ."Messages"
        ."VALUES"
           ."(null,'$user_id','$subject','$msg')";
    mysqli_query($conn,$query) or die (mysqli_error($conn));
}