( ! ) Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\editp.php on line 9

Viewed 21

I am getting the error:

( ! ) Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\editp.php on line 9

when I try to run my PHP page. I am expecting this problem is originating from either the $sql or the $connection. I don't believe it is my $connection because all of my variables are correct and I am not getting a connection error. The code is supposed to update my MySQL table's data three rows.

Here is my full PHP page's code:

 <?php   
 session_start();  
 $conn=mysqli_connect("localhost","root","","test");  
         include_once "connection.php";
         
          $id = $_SESSION['id'];
       
          $req = mysqli_query($con , "SELECT * FROM comptess WHERE id = $id");
          $row = mysqli_fetch_assoc($req);


       
       if(isset($_POST['button'])){
           
           extract($_POST);
           
           if(isset($nom) && isset($prenom) && isset($email)){
               //requête de modification
               $req = mysqli_query($con, "UPDATE comptess SET nom = '$nom' , prenom = '$prenom' , email = '$email' WHERE id = $id");
                if($req){
                    header("location: editp.php");
                }else {//si non
                    header("location: editp.php");
                }

           }else {
               
               header("location: editp.php");
           }
       }
       
       
    

   
 ?> 
0 Answers
Related