Home » Php » php – I nottice the following errors

php – I nottice the following errors

Posted by: admin February 25, 2020 Leave a comment

Questions:

Notice: Undefined variable: con in F:\xampp\htdocs\IMEProgram\news-single.php on line 23

Warning: mysqli_query() expects parameter 1 to be mysqli, null given
in F:\xampp\htdocs\IMEProgram\news-single.php on line 23

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result,
null given in F:\xampp\htdocs\IMEProgram\news-single.php on line 25

<?php
 $query = "select * from posts";

  $con = mysqli_query($con,$query);

 while ($row = mysqli_fetch_assoc($con))
  {
  $post_title = $row['post_title'];
  $post_author = $row['post_author'];
  $post_date = $row['post_date'];
  $post_img = $row['post_img'];
  $post_content = $row['post_content'];
  $post_tags = $row['post_tags'];
  }
 ?>
How to&Answers: