我有以下代码:
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?
改变这个
if(mysqli_affected_rows($con, $insert_member_res)>0)
至
if(mysqli_affected_rows($con)>0)
mysqli_affected_rows只需要connection link对象,但您传递了查询对象,这也是问题所在
mysqli_affected_rows
connection link