How to express the success of the query?

Please see here
expression of successful query

if ($conn->query($sql) === TRUE) {
    echo "";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

Please see my code:

<form action="" type="text" method="get">
<div>
    :
    <input type="text" name="keyword">
    <select id="" name="sel">
        <option value="title"></option>
        <option value="content"></option>
        <input type="submit" value="">
    </select>
</div>
</form>

<?php
    require("conn.php");
    $keyword = trim($_GET["keyword"]);
    $sel = $_GET["sel"];
    $sql = "SELECT * FROM lyb where $sel  " . "  like "%$keyword%"";
    if ( $mysqli->query($sql) === TRUE) {
        echo "<br />";
    } else {
        echo "</br />" . $mysqli->error;
    }
    $result = $mysqli->query($sql);
    echo "$result->num_rows"."<br />";
    var_dump($result);
?>

query failed
20
object (mysqli_result)-sharp2 (5) {["current_field"] = > int (0) ["field_count"] = > int (8) ["lengths"] = > NULL ["num_rows"] = > int (20) ["type"] = > int (0)}

inconsistency, ha,
1. The query failed, why are there still 20 results?
2. If the query fails, why. $mysqli- > error has no output?

Apr.09,2021

= true?


check the judgment condition

mysqli::query returned value:

return FALSE, on failure successful execution of SELECT, SHOW, DESCRIBE or EXPLAIN queries via mysqli_query () returns a mysqli_result object, while other queries return TRUE.

manual: http://php.net/manual/zh/mysq.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34761-2bf09.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34761-2bf09.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?