I am very new to PHP so please help if you can.
The code I am working on is simple to most of you I know. All I am trying to do is produce the out put from a database and have the fields displayed on different lines on the screen.
Below id the code I am working with:
<?php
include 'error.inc';
include 'db.inc';
function displayhotels($result)
{
// Start a table, with column headers
echo "\n<table border=\"0\" cellpadding=\"2\" cellspacing\"1\">" .
"<caption><b><font color=\"black\" size=\"-1\"> Warwickshire Hotels</b></caption>" .
"\n\t<th width=\"10%\" bgcolor=\"#cccccc\" ><font color=\"black\" size=\"-1\" >Code </th>" .
"\n\t<th width=\"40%\" bgcolor=\"#cccccc\"><font color=\"black\" size=\"-1\" face=\"airal\"><b>Hotel Name </th>" .
"\n\t<th width=\"15%\" bgcolor=\"#cccccc\"><font color=\"black\" size=\"-1\" >Telephone No </th>" .
"\n\t<th width=\"15%\" bgcolor=\"#cccccc\"><font color=\"black\" size=\"-1\" >Faxsmile No </th>" .
"\n\t<th width=\"20%\" bgcolor=\"#cccccc\"><font color=\"black\" size=\"-1\" >Email Address </th>" .
"\n\t<th width=\"10%\" bgcolor=\"#cccccc\" ><font color=\"black\" size=\"-1\" >Website </th>" .
"\n</tr>";
echo "\n<tr>\n\t<td></td>\n</tr>";
echo "\n<tr>\n\t<td></td>\n</tr>";
echo "\n<tr>\n\t<td></td>\n</tr>";
// Until there are no rows in the result set,
// fetch a row into the $row array and ...
while ($row = @ mysql_fetch_row($result))
{
// ... start a TABLE row ...
echo "\n<tr>";
// ... and print out each of the attributes
// in that row as a separate TD (Table Data).
foreach($row as $data)
echo "\n\t<td bgcolor=\"#ffffff\"><font size=\"-1\"face=\"airal\"> $row["name"] . " ". </td>";
echo "\n\t<td bgcolor=\"#ffffff\"><font size=\"-1\"face=\"airal\"> $row["street"] . " " . </td>";
// echo "\n<tr>\n\t<td></td>\n</tr>";
// echo "\n<tr>\n\t<td></td>\n</tr>";
// echo "\n<tr>\n\t<td></td>\n</tr>";
// Finish the row
echo "\n</tr>";
}
// Then, finish the table
echo "\n</table>\n";
}
//$query = "SELECT name, street, FROM accom order by name";
$query ="select
set name = $name, " .
street = $street, " .
from accom order by name";
// Connect to the MySQL server
if (!($connection = @ mysql_connect($server,
$user,
$password)))
die("Cannot connect");
if (!(mysql_select_db("db66511019", $connection)))
showerror();
// Run the query on the connection
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// Display the results
displayhotels($result);
// Close the connection
if (!(mysql_close($connection)))
showerror();
?>
When I run the code I get the following error:
I did say I was new to this.
Parse error: parse error, expecting T_STRING' orT_VARIABLE' or `T_NUM_STRING'
Can anyone help.
Kind regards.
Dereck