Non-specific errors, no apparent cause
<p>I am a newbie, working through exercises in 'Database Driven Websites'.</p>

<p>The following PHP gives two errors that a couple of hours of pondering and searching have not cleared up.</p>

<p>When I call the page from a browser I get: </p>

<blockquote>
  <p>Parse error: syntax error, unexpected $end in /home/copydesign/www/listjokes.php on line 54</p>
</blockquote>

<p>Line 54 is: "", which seems right to me.</p>

<p>In BBedit an error is indicated for line #51, which is a blank line. Line #50 is "?>" to indicate the end of PHP parsing. I hate to ask if I should be able to solve this for myself but if anyone can help me I'll be most appreciative. </p>

<hr>

<p>Here is the entire page:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;The CopyDesign Internet Joke Database&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;?php if (isset($_GET['addjoke'])): // Visitor wants to add a joke
?&gt;

&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
&lt;label&gt;Type a joke here:&lt;br /&gt;
&lt;textarea name="joketext" rows="10" cols="40"&gt;
&lt;/textarea&gt;&lt;/label&gt;&lt;br /&gt;
&lt;/form&gt;

&lt;?php else: // Display default page

// Open a MySQL connection

$dbcnx = @mysql_connect('solas.phpwebhosting.com', 'copydesign', 'keylock');

// Select the joke database
if (!@mysql_select_db('ijdb')) {
exit('&lt;p&gt;Unable to connect to the joke database at this time.&lt;/p&gt;');
}

?&gt;

&lt;p&gt;CopyDesign's Internet Joke Database:&lt;/p&gt;

&lt;blockquote&gt;

&lt;?php

// Request the text of all the jokes
$result = @mysql_query('SELECT joketext FROM joke');
if (!result) {
exit('&lt;p&gt;Error performing query: ' . 
mysql_error() . '&lt;/p&gt;');
}

// Display the text of each joke in a paragraph
while ($row = mysql_fetch_array($result)) {
echo '&lt;p&gt;' . $row['joketext'] . '&lt;/p&gt;';
}

?&gt;

&lt;/blockquote&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
