我准备的声明更新存在问题
$query = "UPDATE kids_entry SET entries=? WHERE parentsemail=?";
$stmt1 = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt1, 'is',$entries,$parentsemail);
mysqli_execute($stmt1);
if(mysqli_stmt_affected_rows($stmt1) != 1)
die("issueasdass");
mysqli_stmt_close($stmt1);
上面的代码在另一个页面上确实对我有用,但我似乎无法让它在这里工作。在另一页上,要更新的设置是硬编码的并且不是动态的,因此这可能就是它对我不起作用的原因。有人可以告诉我我做错了什么吗?谢谢
$query = "UPDATE kids_entry SET entries=? WHERE parentsemail=?";
$stmt1 = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt1, 'is',$entries,$parentsemail);
mysqli_execute($stmt1);
if(mysqli_stmt_affected_rows($stmt1) != 1)
die("issueasdass");
mysqli_stmt_close($stmt1);
The above code does work for me on another page but i cannot seem to get it to work here. On the other page the set to update is a hardcoded in and is not dynamic so that might be why it isn't working for me. Can someone tell me what I am doing wrong? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
条目的值是否可能与数据库中已有的值相同?我认为如果没有任何变化,
*_affected_rows
不会返回 1。是否可能有超过 1 个“parentsemail”条目?那么也许 mysqli_stmt_affected_rows 会返回类似 2 的内容?也许让我们知道 mysql_stmt_affected_rows 正在返回什么,而不是检查 1。例如,来自文档:Is it possible that entries is the same value as what's already in the database? I don't think
*_affected_rows
returns 1 if nothing changes. Is it possible that there's more than 1 entry for 'parentsemail'? So perhapsmysqli_stmt_affected_rows
is returning something like 2? Instead of checking 1, maybe let us know whatmysql_stmt_affected_rows
is returning. For example, from the docs:这个问题似乎已经自行解决。没有任何改变,但现在可以了!
The issue appears to have resolved itself. Nothing has changed but now it works!