Does anyone sees any fault?

             $sql = 'SELECT * FROM messages';
$result = $database->sql_query($sql);

while ($row = $database->sql_fetchrow($result))
   echo $row['message'];

and my database connection

$database = mysql_select_db(DB_DATABASE) or die(mysql_error());

$database = mysql_select_db(DB_DATABASE)

That returns a resource.


This implies an object.

Where did you get that code? I think you are mixing up different solutions. Check the PHP code snippets, there are samples for MySQL, MySQLi and PDO.

I believe that it should look something like this:

$my_conn = new mysqli('localhost', 'user name', 'password', 'database name');
$sql = "SELECT * FROM messages";
$result = $my_conn->query($sql);
while ($obj = $result->fetch_object()) {
    echo = $obj->message;

I could easily be wrong though ...

hope this helps,


use this piece of code and replace dbname with your database name

$qry = mysql_query("SELECT * FROM messages");
while ($row = mysql_fetch_array($qry))
   echo $row['message'];?><br /><?php

hope this helps you.

Yes it helped thanks very much