[英]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 Mysql语句
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). 设置$ event_id和$ user_id(24和25)。 The Connection works correct, the SQL-Querys before works correct. 连接工作正常,之前的SQL查询工作正常。
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! 您必须绑定变量!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.