插入到mysql数据库不工作没有给出错误

时间:2015-02-28 19:15:21

标签: php mysql

检索禁令有效,但是当我尝试向数据库输入新的禁令时,没有任何反应。没有错误或任何东西。

function get_mysql() {
    $mysql = new mysqli("localhost", "user", "pass", "table");

    if ($mysql->connect_error) {
        die($mysql->connect_error);
    }

    return $mysql;
}

//ban stuff
    //bans the player given a uuid, moderator, an Expiration date and a reason
    function ban($uuid, $moderator, $expiration, $reason) {
        get_mysql()->query("INSERT INTO banLogger (UUID, Moderator, Expiration, Reason) values ('$uuid', '$moderator', '$expiration', '$reason'");
    }

    //returns all the bans for a specific player
    function get_ban_by_player($uuid) {
        return get_mysql()->query("SELECT * FROM banLogger where UUID = '$uuid'")->fetch_assoc();
    }

    //returns all the bans
    function get_all_bans() {
        return get_mysql()->query("SELECT * FROM banLogger")->fetch_assoc();
    }

运行实际代码

ban('051a6abd-37a9-48bd-a815-55aab7290206', 'mod', '2015-02-04 00:00:00',     'testing');

MySQL structure

1 个答案:

答案 0 :(得分:1)

插入查询的值中缺少关闭括号,它应该是:

"INSERT INTO banLogger (UUID, Moderator, Expiration, Reason) values ('$uuid', '$moderator', '$expiration', '$reason')"