PHP插入中的mysqli_affected_rows [英] mysqli_affected_rows in PHP insert
本文介绍了PHP插入中的mysqli_affected_rows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有此代码:
if(mail($to, $subject, $message, $headers)){
$insert_member_sql = "INSERT INTO members (id, username) VALUES('$id', '$username')";
$insert_member_res = mysqli_query($con, $insert_member_sql);
if(mysqli_affected_rows($con, $insert_member_res)>0){
echo "1";
}else{
echo "0";
}
};
在发送电子邮件并将信息插入数据库中时,一切都工作正常,但是mysqli_affected_rows无法正常工作-运行查询后,如何编辑此代码以回显1?
All is working fine with the sending of an email and inserting the information to a database but the mysqli_affected_rows isn't working - How can I edit this code to echo 1 after running the query?
推荐答案
更改此内容
if(mysqli_affected_rows($con, $insert_member_res)>0)
到
if(mysqli_affected_rows($con)>0)
mysqli_affected_rows
仅需要connection link
对象,但是您也传递了查询对象,这就是问题所在
mysqli_affected_rows
only requires connection link
object but you passed query object also that was the problem
这篇关于PHP插入中的mysqli_affected_rows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文