-
With the following code, I seem to get a parse error on the last line (the </html> bit) can anyone spot any errors?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<BODY>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb");
// Display individual Record
if($id) {
$strSQL = "SELECT * FROM employees WHERE id=$id";
$result = mysql_query($strSQL);
$myrow = mysql_fetch_array($result);
echo("First Name: ".$myrow[first]."\n<br>");
echo("Last Name: ".$myrow[last]."\n<br>");
echo("Address: ".$myrow[address]."\n<br>");
echo("Position: ".$myrow[position]."\n<br>");
}
else {
// show employee list
$result = mysql_query("SELECT * FROM employees");
if($myrow = mysql_fetch_array($result)) {
do {
echo("<a href=".$PHP_SELF."id=".$myrow["id"].">".$myrow[first]." ".$myrow[last]."</a><br>\n");
} while ($myrow = mysql_fetch_array($result));
}
else
{
echo("Sorry No Records Found");
}
}
</body>
</html>
-
I just browsed it quickly, but I did notice one thing.
Try adding a ?> before the last two html tags.
?>
</body>
</html>
-
THANK YOU, THANK YOU, I spent ages trying to figure it out last night, it was driving me CRAZY.
I cant believe I overlooked such a simple thing.
Oh well at least Ill know for next time :)
-
If you get an error on the last line (or the line after that), the problem is almost always one of:
missing ?>
missing }
unterminated string
Christian