, , ,

Whenever you’re updating your PHP form data and getting a warning: count(): error message on the above page? How can you fix it?

Posted by

Suppose, you’re working on a PHP form on the working principle of crud operation and have pre-filled inserted data on your table. And if you want to update or edit your data table, whenever you click on the edit button and it shows the warning error over the page that I have marked below on the image:

PHP Warning Error

I have a solution for you, if you’re continuously getting this kind of warning error then you have something error in your PHP code function then you have such type of ‘edit’ code function that I have mentioned below on the code image:

if(isset($_GET['edit'])){
    $id=$_GET['edit'];
    $update= true;
    $result = $mysqli->query("SELECT * FROM wishform WHERE id=$id") or die($mysqli->error()); 
   if (count($result)==1){
      $row = $result->fetch_array();
      $title=$row['title'];
      $details=$row['details'];
      $name=$row['name'];
      $date=$row['date'];
      $email=$row['email'];
      $phone=$row['phone'];
   }
}

So, you will replace something from the code, I have replaced it on my edit code function and that really works for me. if you apply this below-mentioned code on your PHP edit function then you’ll get rid of unwanted error messages on your php crud operation:

if(isset($_GET['edit'])){
    $id=$_GET['edit'];
    $update= true;
    $result = $mysqli->query("SELECT * FROM wishform WHERE id=$id") or die($mysqli->error()); 
   if (!is_null($result)==1){
      $row = $result->fetch_array();
      $title=$row['title'];
      $details=$row['details'];
      $name=$row['name'];
      $date=$row['date'];
      $email=$row['email'];
      $phone=$row['phone'];
   }
}

I’ll make sure that it will really work for you. I hope that it will solve your PHP crud issue and better your code functionality.

guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x