mysqli_affected_rows ($ connection) does not work [closed]

1

Colleagues.

I'm working with Linux now and separately installed Apache, PHP and Mysql, but in tests with some systems, I noticed that mysqli_affected_rows () does not work. The test was based on this code:

session_start();
ini_set('display_errors',1);
ini_set('display_startup_erros',1);
error_reporting(E_ALL);    

    $conexao = mysqli_connect('127.0.0.1','root','111488','bd_construcao');

    $ip = $_SERVER['REMOTE_ADDR'];
    $email = filter_input(INPUT_POST,"Email",FILTER_VALIDATE_EMAIL);

    mysqli_query($conexao,"INSERT INTO tb_cadastros VALUES(null,'".$ip."','".$email."',NOW());");

    if(mysqli_affected_rows($conexao) > 0)){
            $_SESSION["Sucesso"] = time() + 3;
      }else{
            $_SESSION["Erro"] = time() + 3;
            $_SESSION["Mensagem"] = "Erro...";
     }

No error is displayed, data is not entered and the page is left blank. But when I take the line:

if(mysqli_affected_rows($conexao) > 0)){
            $_SESSION["Sucesso"] = time() + 3;
      }else{
            $_SESSION["Erro"] = time() + 3;
            $_SESSION["Mensagem"] = "Erro...";
}

The registration is done.

    
asked by anonymous 16.07.2017 / 22:19

0 answers