Information updated database however returns false


I have the following block of code which checks if information was updated correctly in MYSQL.
After running the script the information is updated correctly in the database however.
“if ($result && mysqli_affected_rows($link) > 0)”

returns false I do not understand why.

Here is my code:

if (isset($_POST[‘submit_update_post’])){

 // This part of code is for inputting the information back into the database
     $info_posted = $_POST['edit_info_posted'];
     $link = db_connect(); 
     $sql = "UPDATE posts SET text = $info_posted WHERE post_id = $edited_post_id ;";
     $result = mysqli_query($link, $sql);
     if ($result && mysqli_affected_rows($link) > 0){
     $message = "You successfully updated the information in the database";
        else {
        $message ="David is king";

Thank you for your help


So which one returns false, $result or mysqli_affected_rows? Use var_dump()


Your page is probably being requested twice. The first time, the data gets updated. The second time, the data is the same, so the affected rows value is zero. How is your form being submitted?