Hi I submitted the question about text files I decided to have a go with a database instead though Im having problems connecting to the Database. As a PHP novice Im not entirely sure where Im going wrong but I have been getting the following error:
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in E:\html\dbconn.php on line 4
Can't select entries from table.
SELECT * FROM Entry ORDER BY Entry.entryDate DESC LIMIT 5
No Database Selected
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\html\dbconn.php on line 11
The code I'm using looks like this:
<?php
mysql_connect ('localhost');
mysql_select_db("database",$dbh);
$sql = "SELECT * FROM Entry ORDER BY Entry.entryDate DESC LIMIT 5";
$result = mysql_query($sql) or
print ("Can't select entries from table.<br />" . $sql . "<br />" . mysql_error());
while ($row = mysql_fetch_array($result))
{
$date = $row["entryDate"];
$title = $row["entryTitle"];
$entry = $row["entryText"];
print "<b>$title</b><br><br>";
print "$entry<br><br>";
print "posted on $date<br><br>";
print "<hr><br><br>";
}
?>
any pointers to where Im going wrong would be great - thanks!