I've also tried doing it this way:
<html>
<?php
$dbh=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("***");
if ($Date)
{
$query = ("SELECT * FROM Availability WHERE " . "Date=$Date");
$result = mysql_query($query);
if (!$rec = mysql_fetch_row($result))
{
echo ("Sorry, no records found");
}
else {
do {
print "<font size=2 face=Verdana>The following date was found:</font><br><br>\n";
print "<font size=2 face=Verdana><b>Date:</b> " . $rec["Date"] . "</font><br>\n";
print "<font size=2 face=Verdana><b>Cabin 123:</b> " . $rec["Cabin123"] . "</font><br>\n";
print "<font size=2 face=Verdana><b>Cabin 190:</b> " . $rec["Cabin190"] . "</font><br>\n";
print "<font size=2 face=Verdana><b>Price:</b> £" . $rec["Price"] . "</font><br><br>\n";
print "<font size=2 face=Verdana><a href=dateform.php><font color=#996633>Enquire about booking this date</font></a></font><br>\n";
}
while ($rec = mysql_fetch_row($result));
}
}
?>
<form action="<?php echo $PHP_SELF?>" method="post">
Date: <input type="number" name="Date">
<input type="submit" value="Search Database">
</form>
</html>
But it prints out the following error message:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in test.php on line 12