Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in D:\xampp\htdocs\Kurs\include\news.php on line 32
I get this error and i cant understand why its a simple code and there shouldn't be any error. Here is my code:
<?php
$select_news = "SELECT title, content, date_created FROM news ORDERED BY date_created DESC LIMIT 4";
$run_news = mysqli_query($con, $select_news);
while ($news = mysqli_fetch_assoc($run_news)){
$post_title = $news['title'];
$post_content = $news['content'];
$post_date = $news['date_created'];
?>
<div id='c'>
<div class='tit'><span class='k'><?php echo $post_title; ?></span></a><text><?php echo $post_date; ?></text></div></br>
<div class='comment more'><?php echo $post_content;?></div></br>
<div id='cherta'>-------------------------------------------------------------------------------------------------------------------------</div>
</div>
<?php
}
?>
I included and the connect.php file who connects me to the DB and here is the code of my connect file:
<?php
$con= mysqli_connect("localhost","root","waterpolo387","kurss");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>