Skip to main content
Known Participant
February 19, 2011
Question

Parse error help

  • February 19, 2011
  • 2 replies
  • 517 views

I am getting this message after uploading a site to the remote server:

Parse error:  syntax error, unexpected '{' in /home/content/w/i/l/wildfelid/html/scripts/user_authentication.php on line 9

I cannot find any syntax problem and was hoping other eyes might see something I haven't been able to.

This is the user_authentication.php code:

<?php
$failed = FALSE;
if ($_POST) {
  if (empty($_POST['username']) || empty($_POST['password'])) {
    $failed = TRUE;
  } else {
    require_once('library.php');
    // check the user's credentials
    try {
      $auth = Zend_Auth::getInstance();
      $adapter = new Zend_Auth_Adapter_DbTable($dbRead, 'users', 'username', 'password');
      $adapter->setIdentity($_POST['username']);
      $adapter->setCredential($_POST['password']);
      $result = $auth->authenticate($adapter);
      if ($result->isValid()) {
        $storage = $auth->getStorage();
        $storage->write($adapter->getResultRowObject(array(
          'username', 'first_name', 'last_name')));
        header('Location: members_only.php');
        exit;
      } else {
        $failed = TRUE;
      }
    } catch (Exception $e) {
      echo $e->getMessage();
    }
  }
}
if (isset($_GET['logout'])) {
  require_once('library.php');
  try {
    $auth = Zend_Auth::getInstance();
    $auth->clearIdentity();
  } catch (Exception $e) {
    echo $e->getMessage();
  }
}

The library.php connection file used by the above file looks like this:

<?php
// Adjust the path to match the location of the library folder on your system
$library = '/home/content/w/i/l/wildfelid/html/library/ZendFramework/library';
set_include_path(get_include_path() . PATH_SEPARATOR . $library);
require_once('Zend/Loader/Autoloader.php');
try {
      Zend_Loader_Autoloader::getInstance();
  $write = array('host'     => 'p50mysql15.secureserver.net',
                 'username' => 'username',
                 'password' => 'password',
                 'dbname'   => 'wildfelid');
  $read  = array('host'     => 'p50mysql15.secureserver.net',
                 'username' => 'usernameRead',
                 'password' => 'password',
                 'dbname'   => 'wildfelid');


  $dbWrite = new Zend_Db_Adapter_Pdo_Mysql($write);
  $dbRead = new Zend_Db_Adapter_Pdo_Mysql($read);

} catch (Exception $e) {
    echo $e->getMessage();
}

Usernames and passwords have been changed to protect the innocent. These may look familiar to some as based on lessons in David Powers' DW CS5 with PHP book. Unfortunately David seems occupied elsewhere right now. Any help would be greatly appreciated.

Peter

This topic has been closed for replies.

2 replies

David_Powers
Inspiring
June 13, 2011

conmolbry wrote:

I am getting this message after uploading a site to the remote server:

Parse error:  syntax error, unexpected '{' in /home/content/w/i/l/wildfelid/html/scripts/user_authentication.php on line 9

I cannot find any syntax problem and was hoping other eyes might see something I haven't been able to.

I don't see any syntax errors in your code. I assume from your first sentence that the code worked fine in your local testing environment. That raises two possibilities:

  1. The path to the Zend Framework is incorrect.
  2. If the path is OK, the other possibity is that your remote server doesn't support PDO. Check phpinfo() on the remote server.
June 10, 2011

I'm having this problem at the moment - but only if I upload through Dreamweaver (CS5.5)

If I use CuteFTP I don't get this problem.

Kinda points at Dreamweaver screwing the files up when it uploads them.

Cheers

Ian