I have created a form which successfully writes to a database but I'm getting this error message when I try to print out the database:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /../../../guest_list.php on line 43
Sorry, no records were found!
Line 43 of the code reads:
if ($row = mysql_fetch_array($result)) {
The php code of the page is this:
<?php
mysql_connect (localhost, username, password);
mysql_select_db (db_name);
$result = mysql_query ("SELECT 'LastName', 'FirstName', '_Guest', 'Accommodation', FROM 'guest'");
if ($row = mysql_fetch_array($result)) {
do {
print ("<tr>");
print ("<td>");
print $row["LastName"];
print ("</td>");
print ("<td>");
print $row["FirstName"];
print ("</td>");
print ("<td>");
print $row["_Guest"];
print ("</td>");
print ("<td>");
print $row["Accommodation"];
print ("</td>");
print ("</tr>");
} while($row = mysql_fetch_array($result));}
else {print "Sorry, no records were found!";}
?>
I can't figure out what I need to change in order for it to write the table of results