Flames, your code wouldnt work because its mot the localhost. The hos tis the 000webhost host.
Try this (Similar to what youve got just less complicated.
PHP Code:
<?php
$host = 'mysql3.000webhost.com'; $user = 'YOUR USER'; $pass = 'YOUR PASS'; $db = 'DATABASE NAME';
mysql_connect($host,$user,$pass)or die(mysql_error());
mysql_select_db($db)or die(mysql_error());
?>
Rather then fiddling with all this other rubbish and making variables for ecerything, just keep it plain and simple and do the query without making it into a variable etc.
I would also change your query to:
PHP Code:
<?php
$selectnews = mysql_query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 3");
while ($getnews = mysql_fetch_assoc($selectnews)){
echo "<li><h3>".$getnews['date']."</h3>"
echo "<p>".$getnews['message']."</p></li>";
}
?>
I have changed the "fetch_array" to "fetch_assoc" which does pretty much the same thing; only has a minor different which you can check on php.net. As has already been said you may have a null value in there but that WOULDN't return the error youve been given. It would just echo nothing, in other words give a blank space.
That error is when you have something wrong in your code for example:
PHP Code:
<?php
$query = mysql_query("SELECT * FROM `news` WHERE `name` = '$name'");
$result = mysql_fetch_array($yreuq);
echo ''.$result['news'];
?>
Notice how i spelt query backwards. That is when you would get that sort of error because it cant find anything with that variable. If i were you id check all your spelling etc as ive made that mistake before!