0

Hello, I expect it returns to either -1 or 1 but boolean.

$dbc = mysqli_connect("localhost", "root", "","test_site") or die ("SQL could not connect to database!.");

        $query = "INSERT INTO user_accounts(member_type,username,password,name,email,country) 
        VALUES ('$membertype','$username','$password','$name','$email','$country')";

        $result = mysqli_query($dbc, $query);
        $registered =mysqli_affected_rows($result);

        if($registered>0)
            echo "Registered Successfully.";
        else
            echo "Your registration is unsuccessful.";

        mysqli_close($dbc);

Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, boolean...

2
Contributors
1
Reply
8
Views
3 Years
Discussion Span
Last Post by gabrielcastillo
0

Try a more updated way of mysqli.

Example.

 $dbc = new mysqli('localhost', 'user', 'pass', 'demo');

    $sql = "INSERT INTO table_name(``,``,``,``) VALUES('','','','');

    $results = $dbc->query($sql);

    echo 'Total Rows: ' .  $dbc->affected_rows;

    $results->free();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.