mysqli_affected_rows in PHP insert

前端 未结 3 448
情歌与酒
情歌与酒 2020-12-07 00:15

I have this code:

if(mail($to, $subject, $message, $headers)){
    $insert_member_sql = \"INSERT INTO members (id, username) VALUES(\'$id\', \'$username\')\"         


        
相关标签:
3条回答
  • 2020-12-07 00:41

    change this

    if(mysqli_affected_rows($con, $insert_member_res)>0)
    

    to

    if(mysqli_affected_rows($con)>0)
    

    mysqli_affected_rows only requires connection link object but you passed query object also that was the problem

    0 讨论(0)
  • 2020-12-07 00:48

    or you can echo it

    echo mysqli_affected_rows($con);
    

    in case you want to double check of course

    0 讨论(0)
  • 2020-12-07 00:56
    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";
        }
    };
    
    0 讨论(0)
提交回复
热议问题