0
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo '<div class="post" title="Timestamp: '. $row["clock"] .'">';
        echo '<div class="handle"><div class="tripcode">' . $row["tripcode"]. '</div><div class="user">&lt;<div class="name">'. $row["handle"]. '</div>&gt;</div></div><div class="message">' . $row["message"]. '</div><br>';
        echo '</div>';
    }
} else {
    echo "0 results";
}
$conn->close();

source code = http://pastebin.com/qahkB6mt

the error i got was:

Notice: Trying to get property of non-object in /storage/h1/206/469206/public_html/h/chat.php on line 102

0 results

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Ian
  • 1
  • it's a notice not an error. Do you have records on your database? because you are executing the code in the else condition – Rafael Shkembi Jan 05 '17 at 09:03
  • It might be nice if you were to indicate which is line 102 in this 12 line code fragment – RiggsFolly Jan 05 '17 at 09:03
  • 2
    The most likely reason is that the query failed. As you dont bother checking for that maybe you should – RiggsFolly Jan 05 '17 at 09:04
  • Add `ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);` to the top of your script. This will force any `mysqli_` errors to generate an Exception that you cannot miss or ignore. – RiggsFolly Jan 05 '17 at 09:05

0 Answers0