我有这段代码:
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?
答案 0 :(得分:4)
更改此
if(mysqli_affected_rows($con, $insert_member_res)>0)
到
if(mysqli_affected_rows($con)>0)
mysqli_affected_rows
只需要connection link
个对象,但您也传递了查询对象也是问题
答案 1 :(得分:2)
或者你可以回应它
echo mysqli_affected_rows($con);
如果您想要仔细检查课程
答案 2 :(得分:1)
if(mail($to, $subject, $message, $headers)){
$insert_member_sql = "INSERT INTO members (id, username) VALUES('$id', '$username')";
if (!mysql_query($insert_member_sql) ){
echo "1";
}else{
echo "0";
}
};