调用 mysql_insert_id 会发出警告
您好,我在尝试检索插入 ID 时收到此警告
警告:mysql_insert_id():已提供 参数不是有效的 MySQL-Link 资源
在
mysql_query($importword);
$word_id = mysql_insert_id($importword);
Hi I'm receiving this warning when trying to retrieve the insert id
Warning: mysql_insert_id(): supplied
argument is not a valid MySQL-Link
resource
in
mysql_query($importword);
$word_id = mysql_insert_id($importword);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果你得到了 id 和你想要插入的 id,只需写
mysql_insert_id();在您的查询之后。
if you get the id and that id you want to insert just write
mysql_insert_id(); after your query.
$importword
是您使用msql_query
执行的查询。接下来,您将查询传递给
mysql_insert_id
,这是不正确的。 mysql_insert_id 采用链接标识符是可选的。如果您没有打开多个连接,则不要传递任何内容:
以便它使用
mysql_connect
打开的最后一个链接$importword
is the query that you are executing usingmsql_query
.Next you are passing the query to
mysql_insert_id
which is incorrect. mysql_insert_id takes the link identifier which is optional.If you are not having multiple connections open, just don't pass anything:
so that it uses the last link opened by
mysql_connect
您应该传递连接,或者将其留空以使用最后打开的连接。
You're supposed to pass the connection, or leave it empty to use the last one opened.
mysql_insert_id 采用资源标识符而不是查询
传递资源或留空
mysql_insert_id take the resource identifier not the query
either pass resource or leave blank