Hey everyone. I was learning how to make a simple content system for my website today and I was following along the code at css-tricks.com and when I was all finished, I got this error saying:

Parse error: syntax error, unexpected $end in /home/gosports/public_html/gsbadmin/_class/simpleCMS.php on line 107

I read up on other posts about parse errors, in most cases where brackets are not closed or shortened php code like <? is used rather than <?php. Well I can't figure out what's wrong for the life of me.

If it helps at all, simpleCMS.php is located in the _class/ directory

Can anyone please help?

        <link rel="stylesheet" href="style.css">   


class simpleCMS {
  var $host;
  var $username;
  var $password;
  var $table;

  public function display_public() {
    $q = "SELECT * FROM annoucements ORDER BY created DESC LIMIT 3";
    $r = mysql_query($q);

    if ( $r !== false && mysql_num_rows($r) > 0 ) {
      while ( $a = mysql_fetch_assoc($r) ) {
        $title = stripslashes($a['title']);
        $bodytext = stripslashes($a['bodytext']);

        $entry_display .= <<<ENTRY_DISPLAY


    } else {
      $entry_display = <<<ENTRY_DISPLAY

    <h2>This Page Is Under Construction</h2>
      No entries have been made on this page.
      Please check back soon, or click the
      link below to add an entry!

    $entry_display .= <<<ADMIN_OPTION

    <p class="admin_link">
      <a href="{$_SERVER['PHP_SELF']}?admin=1">Add a New Entry</a>


    return $entry_display;

  public function display_admin() {
    return <<<ADMIN_FORM

    <form action="{$_SERVER['PHP_SELF']}" method="post">
      <label for="title">Title:</label>
      <input name="title" id="title" type="text" maxlength="150" />
      <label for="bodytext">Body Text:</label>
      <textarea name="bodytext" id="bodytext"></textarea>
      <input type="submit" value="Create This Entry!" />


  public function write($p) {
    if ( $p['title'] )
      $title = mysql_real_escape_string($p['title']);
    if ( $p['bodytext'])
      $bodytext = mysql_real_escape_string($p['bodytext']);
    if ( $title && $bodytext ) {
      $created = time();
      $sql = "INSERT INTO annoucements VALUES('$title','$bodytext','$created')";
      return mysql_query($sql);
    } else {
      return false;

  public function connect() {
    mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());
    mysql_select_db($this->table) or die("Could not select database. " . mysql_error());

    return $this->buildDB();

  private function buildDB() {
    $sql = <<<MySQL_QUERY
        CREATE TABLE IF NOT EXISTS annoucements (
            title   VARCHAR(150),
            bodytext    TEXT,
            created VARCHAR(100)

    return mysql_query($sql);

5 Years
Discussion Span
Last Post by diafol

I haven't had a close look, but line 98 should be without the leading whitespace, that is MySQL_QUERY; should be the first thing on that line - no spaces, no tabs.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.