1

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??

Raphael St
  • 661
  • 8
  • 23
  • This is PDO, and not MySQLi, correct? If `$donnees` is not an object, you need to find out why - either the query failed, or something else went wrong earlier in the connection. See [How to squeeze an error message out of PDO](http://stackoverflow.com/questions/3726505/how-to-squeeze-error-message-out-of-pdo) – Michael Berkowski Feb 09 '14 at 16:54
  • What is $bdd an instance of? Add `var_dump($response);` before line 65 to see what it contains. – Bugs Feb 09 '14 at 16:55
  • Oh yes, I remember it. Yes Indeed it is PDO. – Raphael St Feb 09 '14 at 17:16

1 Answers1

0

i would not suggest wampp for development purposes because i too had the same problem instead try using xampp Link:- xampp

Dev Man
  • 2,114
  • 3
  • 23
  • 38