i am trying to do a guestbook in php but i am having some problems with mysql_fetch_array function. I don t understand why. I try to debug by putting die("Error ".mysql_error()) but nothing prints out. I guarantee that all my variables are correctly initialized. Here is my code :
<?php
$nbmessagesPP = 10;
mysql_connect(HOST, USER,PASSWORD) or die( "Unable to connect to database");
mysql_select_db(DBNAME) or die ("Unable to select database!");
.......
if(isset($_GET[ page ])){
$page = $_GET[ page ];
} else {
$page = 1;
}
$first_msg = ($page - 1) * $nb_of_Page;
$query = Select * from livredor ORDER BY id DESC LIMIT .$first_msg. , .$nbmessagesPP;
$rep = mysql_query($query) or exit("Error in query".mysql_error());
$v = true;
while($v){
$v = ($data = mysql_fetch_array($rep) or die ("Error fetching the data : ".mysql_error()));
echo "<p>id -> ".$data[ id ]."</p>";
echo "<p>pseudo ->".$data[ pseudo ]."</p>";
echo "<p>messages ->".$data[ message ]."</p>";
echo "<hr/>";
}
mysql_close();
?>
一个人能够帮助我;