I've created a small website for practising purposes:
This work on WAMP software in local-mode just fine, but when I upload the files up to my server host, it gives me this error :
Fatal error: Call to a member function fetch() on a non-object in /home/XXXXXXXX/public_html/minichat.php on line 65
The code in the file is: (MODIFIED)
$nbrBDD = $bdd->query('SELECT COUNT(ID) AS NBR FROM minichat ');
$donnees2 = $nbrBDD->fetch();
$affichage = $donnees2['NBR']-20;
$affichage2 = $donnees2['NBR'];
$nbrBDD->closeCursor();
$reponse = $bdd->query("SELECT * FROM minichat LIMIT $affichage, $affichage2 ");
while ($donnees = $reponse->fetch()) { ?> //<-This is the 65th line
<div id="message"> <?php
echo $donnees["pseudo"]." : ";
echo $donnees["message"]."<br><br>";
?> </div> <?php
}
$reponse->closeCursor();
?>
Could you explain me how come it would work locally but not on the server??