I have a script on my website which handles a notification system for messages, and alerts. This script pulls in the data from a MySQL Database, and it works like a charm locally, but on my live site, the query fails. This script always returns false and goes to the else condition live, but locally it works exactly the way it should.
$queryNots = 'Select message, DATE_FORMAT(timeSent, "%h:%i %p %W, %M %D ") timeSent FROM notifications WHERE UserID="' . $userId . '" AND seen="n";';
if ($result = $con->query ($query)) {
$resultNum = mysqli_num_rows ( $result );
echo '<h2>You have ' . $resultNum . ' Notifications</h2>
<ul>';
while ( $row = $result->fetch_assoc () ) {
echo '<li>' . $row ["message"] . ' @ ' . $row ['timeSent'] . '</li>';
}
if ($resultNum > 0) {
echo '
</ul>
<form method="post" action="deleteNots.php">
<input type="hidden" name="curID" value="' . $userId . '">
<input type="submit" value="Dismiss">
</form>
';
}
} else {
echo '<h2>Error reading table</h2>';
}
On the live site if I take out the if-else and just run the query not only does it fail, it kills the entire script. I have no idea what could be causing this, I know the tables are the same, because I use them in a different script just fine.
I have absolutely nothing to work with, because it isn't giving me any sort of MySQL error message to go off of. I really want to get this figured out because I want to have this site back working as soon as possible.