0

I have a small piece of code inside a function buts it's not working, even when I pull it out and try it on its own it still doesn't work. I used a MySQL Database Class https://github.com/ajillion/PHP-MySQLi-Database-Class

    require_once('class.mysql.php');
    $_db = new Mysqlidb('localhost', 'root', '', 'database');


    $userCredentials = array(
                        'userID' => 'asdasda',
                        'username' => 'dsdasdasd',
                        'password' => 'v423423c342c23',
                        'email' => '2423v423@gmail.com',
                        'userType' => 1,
                    );

    if($_db->insert('users', $userCredentials)) echo 'success';

The correct data is inserted into the database but Success is not displayed, is their a reason for this?

4

2 回答 2

2

Mysqlidb::insert是错的。它是 return$stmt->insert_id而不是$stmt->execute();. 您的查询不使用自动增量值,因此,您得到 0。

评论提示:

不要使用这个库

于 2013-11-12T02:59:34.320 回答
0

您在作为参数传递的数组末尾有一个额外的昏迷,我认为这不是问题,但仍然......您是否尝试查看通过 var_dump 真正返回的内容?

于 2013-11-12T03:00:20.267 回答