$news = $db->query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1");
while ($item = $news->fetch_assoc()) {
echo $item['msg'];
}
<?php
$post = $mysqli -> query("select * from news order by id desc limit 1 ") -> fetch_assoc();
echo post['msg'];
<?php
$post = $mysqli -> query("select * from news order by id desc limit 1 ") -> fetch_assoc();
echo $post['msg'];
<?php
$post = $mysqli -> query("select * from news order by id desc limit 1 ") -> fetch_assoc();
echo $post['msg'];
Fatal error: Call to a member function query() on a non-object in
<?php
$post = $mysqli->query('select * from news order by id desc limit 1') -> fetch_assoc();
echo $post['msg'];
Fatal error: Call to a member function query() on a non-object in
<?php
$result = $mysqli->query('select * from news order by id desc limit 1');
if ($result->countRow() > 0) {
echo $result->fetchObject()->msg;
}
<?php
$result = $mysqli->query('select * from news order by id desc limit 1')->fetchObject();
if (is_object($result) === true) {
echo $result->msg;
}