我在将数组插入 sql 数据库时遇到了一些麻烦。
我的错误如下:
Unable to add : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '06:45:23,i want to leave a comment)' at line 1 
我的查询 var_dump 是:
string(136) "INSERT INTO news_comments (news_id,comment_by,comment_date,comment) VALUES (17263,Philip,2010-05-11 06:45:23,i want to leave a comment)"
我的问题是如何向 id 添加一个空值,因为它是主键而不是 news_id
我的插入函数如下所示:
function insertQuery($tbl, &$data)
    {
        global $mysqli;
        $_SESSION['errors'] = array();
        require_once  '../config/mysqli.php';
        $query = "INSERT INTO $tbl (".implode(',',array_keys($data)).") VALUES (".implode(',',array_values($data)).")";
        var_dump($query);
        if($result = mysqli_query($mysqli, $query))
        {
        //$id = mysqli_insert_id($mysqli);
        print 'Very well done sir!';
        }
        else
        {
            array_push($_SESSION['errors'], 'Unable to add : ' . mysqli_error($mysqli));
        }
    }
注意:数组不是我的强项,所以我可能会错误地使用它们!