简体   繁体   中英

MYSQLI Insert into doesnt work with no error

This is my Code:

$stmt = $db_main->prepare("INSERT INTO `persons` (`type`, `type_id`, `user_id`) VALUES ('event_organizer', ?, ?)");         
if ($mysqli_error = mysqli_error($db_main))
    die("MYSQLI_ERROR " . $mysqli_error);
$stmt->bind_param('ii', $event_id, $user_id);

The Mysql-Statement

INSERT INTO `persons` 
(`type`, `type_id`, `user_id`) 
VALUES 
('event_organizer', ?, ?)

If I run it I get the error:

Call to a member function bind_param() on a non-object in [...] on line 4. 

But I don't get why. Tablename and Columnnames are correct. $event_id and $user_id are set (24 and 25). The Connection works correct, the SQL-Querys before works correct.

I found my mistake! I forget to close the statement before. After I did this, everything works correctly.

But:

$stmt->bind_param('sii', 'event_organizer', $event_id, $user_id); 

isn't working. You have to bind variables!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM