www.webdeveloper.com
Results 1 to 5 of 5

Thread: Parse Error!

  1. #1
    Join Date
    Dec 2012
    Posts
    7

    Parse Error!

    So I was messing with some code and I ended up messing up the login for my website. It is probably a really simple error that I just can't find but any help would be greatly appreciated. Please put any answers in relatively simple terms! I'm kinda new at this! Thanks!

    Here is the error.... Parse error: syntax error, unexpected T_PRIVATE in /home6/vickysdi/public_html/catalog/controller/account/login.php on line 133
    Here is line 130-145


    $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
    }

    private function validate()
    if (!$this->customer->login($this->request->post['email'], $this->request->post['password'])) {
    $this->error['message'] = $this->language->get('error_login');
    }

    if (!$this->error) {
    return TRUE;
    } else {
    return FALSE;
    }
    }
    }
    ?>

  2. #2
    Join Date
    May 2005
    Posts
    212
    Welcome to the forum.

    Looks like you're missing the brace to open your function.

    private function validate()

    should be

    private function validate() {


    Hope that helps.

    (By the way, your code fragments will be much easier to read if you put them in PHP tags.)

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,926
    I suspect the current error message is the result of something possibly earlier in the code, or a missing closing "}" before the offending line, making that "private function..." unexpected on the cited line number. Then once you fix that, you'll run into the problem scaiferw pointed out, above.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Dec 2012
    Posts
    7

    Rest of the code

    Here is the rest of the code. I added in the extra bracket and it doesn't seem to have solved the error. I suspect it would be something earlier in the code but I have no idea of how to find it. Thanks again for your help!!


    <?php
    class ControllerAccountLogin extends Controller {
    private $error = array();

    public function index() {
    if ($this->customer->isLogged()) {
    $this->redirect(HTTPS_SERVER . 'index.php?route=account/account');
    }

    $this->language->load('account/login');

    $this->document->title = $this->language->get('heading_title');

    if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
    if (isset($this->request->post['account'])) {
    $this->session->data['account'] = $this->request->post['account'];

    if ($this->request->post['account'] == 'register') {
    $this->redirect(HTTPS_SERVER . 'index.php?route=account/create');
    }

    if ($this->request->post['account'] == 'guest') {
    $this->redirect(HTTPS_SERVER . 'index.php?route=checkout/singlepage');
    }
    }

    if (isset($this->request->post['email']) && isset($this->request->post['password']) && $this->validate()) {
    unset($this->session->data['guest']);

    $this->load->model('account/address');

    $address = $this->model_account_address->getAddress($this->customer->getAddressId());

    $this->tax->setZone($address['country_id'], $address['zone_id']);

    if (isset($this->request->post['redirect'])) {
    $this->redirect(str_replace('&amp;', '&', $this->request->post['redirect']));
    } else {
    $this->redirect(HTTPS_SERVER . 'index.php?route=account/account');
    }
    }

    $this->document->breadcrumbs = array();

    $this->document->breadcrumbs[] = array(
    'href' => HTTP_SERVER . 'index.php?route=common/home',
    'text' => $this->language->get('text_home'),
    'separator' => FALSE
    );

    $this->document->breadcrumbs[] = array(
    'href' => HTTP_SERVER . 'index.php?route=account/account',
    'text' => $this->language->get('text_account'),
    'separator' => $this->language->get('text_separator')
    );

    $this->document->breadcrumbs[] = array(
    'href' => HTTP_SERVER . 'index.php?route=account/login',
    'text' => $this->language->get('text_login'),
    'separator' => $this->language->get('text_separator')
    );

    $this->data['heading_title'] = $this->language->get('heading_title');

    $this->data['text_new_customer'] = $this->language->get('text_new_customer');
    $this->data['text_i_am_new_customer'] = $this->language->get('text_i_am_new_customer');
    $this->data['text_checkout'] = $this->language->get('text_checkout');
    $this->data['text_register'] = $this->language->get('text_register');
    $this->data['text_guest'] = $this->language->get('text_guest');
    $this->data['text_create_account'] = $this->language->get('text_create_account');
    $this->data['text_returning_customer'] = $this->language->get('text_returning_customer');
    $this->data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer');
    $this->data['text_forgotten_password'] = $this->language->get('text_forgotten_password');

    $this->data['entry_email'] = $this->language->get('entry_email_address');
    $this->data['entry_password'] = $this->language->get('entry_password');

    $this->data['button_continue'] = $this->language->get('button_continue');
    $this->data['button_guest'] = $this->language->get('button_guest');
    $this->data['button_login'] = $this->language->get('button_login');

    if (isset($this->error['message'])) {
    $this->data['error'] = $this->error['message'];
    } else {
    $this->data['error'] = '';
    }

    $this->data['action'] = HTTPS_SERVER . 'index.php?route=account/login';

    if (isset($this->request->post['redirect'])) {
    $this->data['redirect'] = $this->request->post['redirect'];
    } elseif (isset($this->session->data['redirect'])) {
    $this->data['redirect'] = $this->session->data['redirect'];

    unset($this->session->data['redirect']);
    } else {
    $this->data['redirect'] = '';
    }

    if (isset($this->session->data['success'])) {
    $this->data['success'] = $this->session->data['success'];

    unset($this->session->data['success']);
    } else {
    $this->data['success'] = '';
    }

    if (isset($this->session->data['account'])) {
    $this->data['account'] = $this->session->data['account'];
    } else {
    $this->data['account'] = 'register';
    }

    $this->data['forgotten'] = HTTPS_SERVER . 'index.php?route=account/forgotten';
    $this->data['guest_checkout'] = ($this->config->get('config_guest_checkout') && $this->cart->hasProducts() && !$this->cart->hasDownload());

    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/login.tpl')) {
    $this->template = $this->config->get('config_template') . '/template/account/login.tpl';
    } else {
    $this->template = 'default/template/account/login.tpl';
    }

    $this->children = array(
    'common/column_right',
    'common/footer',
    'common/column_left',
    'common/header'
    );

    $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
    }

    private function validate(){
    if (!$this->customer->login($this->request->post['email'], $this->request->post['password'])) {
    $this->error['message'] = $this->language->get('error_login');
    }

    if (!$this->error) {
    return TRUE;
    } else {
    return FALSE;
    }
    }
    }
    ?>

  5. #5
    Join Date
    Dec 2012
    Posts
    7
    Quote Originally Posted by NogDog View Post
    I suspect the current error message is the result of something possibly earlier in the code, or a missing closing "}" before the offending line, making that "private function..." unexpected on the cited line number. Then once you fix that, you'll run into the problem scaiferw pointed out, above.
    You are probably right. Too bad I don't know php very well... I put in the other bracket and it didn't solve the problem as you suspected... Here is the entire code. Any chance you can help me find the error? Thanks!

    <?php
    class ControllerAccountLogin extends Controller {
    private $error = array();

    public function index() {
    if ($this->customer->isLogged()) {
    $this->redirect(HTTPS_SERVER . 'index.php?route=account/account');
    }

    $this->language->load('account/login');

    $this->document->title = $this->language->get('heading_title');

    if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
    if (isset($this->request->post['account'])) {
    $this->session->data['account'] = $this->request->post['account'];

    if ($this->request->post['account'] == 'register') {
    $this->redirect(HTTPS_SERVER . 'index.php?route=account/create');
    }

    if ($this->request->post['account'] == 'guest') {
    $this->redirect(HTTPS_SERVER . 'index.php?route=checkout/singlepage');
    }
    }

    if (isset($this->request->post['email']) && isset($this->request->post['password']) && $this->validate()) {
    unset($this->session->data['guest']);

    $this->load->model('account/address');

    $address = $this->model_account_address->getAddress($this->customer->getAddressId());

    $this->tax->setZone($address['country_id'], $address['zone_id']);

    if (isset($this->request->post['redirect'])) {
    $this->redirect(str_replace('&amp;', '&', $this->request->post['redirect']));
    } else {
    $this->redirect(HTTPS_SERVER . 'index.php?route=account/account');
    }
    }

    $this->document->breadcrumbs = array();

    $this->document->breadcrumbs[] = array(
    'href' => HTTP_SERVER . 'index.php?route=common/home',
    'text' => $this->language->get('text_home'),
    'separator' => FALSE
    );

    $this->document->breadcrumbs[] = array(
    'href' => HTTP_SERVER . 'index.php?route=account/account',
    'text' => $this->language->get('text_account'),
    'separator' => $this->language->get('text_separator')
    );

    $this->document->breadcrumbs[] = array(
    'href' => HTTP_SERVER . 'index.php?route=account/login',
    'text' => $this->language->get('text_login'),
    'separator' => $this->language->get('text_separator')
    );

    $this->data['heading_title'] = $this->language->get('heading_title');

    $this->data['text_new_customer'] = $this->language->get('text_new_customer');
    $this->data['text_i_am_new_customer'] = $this->language->get('text_i_am_new_customer');
    $this->data['text_checkout'] = $this->language->get('text_checkout');
    $this->data['text_register'] = $this->language->get('text_register');
    $this->data['text_guest'] = $this->language->get('text_guest');
    $this->data['text_create_account'] = $this->language->get('text_create_account');
    $this->data['text_returning_customer'] = $this->language->get('text_returning_customer');
    $this->data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer');
    $this->data['text_forgotten_password'] = $this->language->get('text_forgotten_password');

    $this->data['entry_email'] = $this->language->get('entry_email_address');
    $this->data['entry_password'] = $this->language->get('entry_password');

    $this->data['button_continue'] = $this->language->get('button_continue');
    $this->data['button_guest'] = $this->language->get('button_guest');
    $this->data['button_login'] = $this->language->get('button_login');

    if (isset($this->error['message'])) {
    $this->data['error'] = $this->error['message'];
    } else {
    $this->data['error'] = '';
    }

    $this->data['action'] = HTTPS_SERVER . 'index.php?route=account/login';

    if (isset($this->request->post['redirect'])) {
    $this->data['redirect'] = $this->request->post['redirect'];
    } elseif (isset($this->session->data['redirect'])) {
    $this->data['redirect'] = $this->session->data['redirect'];

    unset($this->session->data['redirect']);
    } else {
    $this->data['redirect'] = '';
    }

    if (isset($this->session->data['success'])) {
    $this->data['success'] = $this->session->data['success'];

    unset($this->session->data['success']);
    } else {
    $this->data['success'] = '';
    }

    if (isset($this->session->data['account'])) {
    $this->data['account'] = $this->session->data['account'];
    } else {
    $this->data['account'] = 'register';
    }

    $this->data['forgotten'] = HTTPS_SERVER . 'index.php?route=account/forgotten';
    $this->data['guest_checkout'] = ($this->config->get('config_guest_checkout') && $this->cart->hasProducts() && !$this->cart->hasDownload());

    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/login.tpl')) {
    $this->template = $this->config->get('config_template') . '/template/account/login.tpl';
    } else {
    $this->template = 'default/template/account/login.tpl';
    }

    $this->children = array(
    'common/column_right',
    'common/footer',
    'common/column_left',
    'common/header'
    );

    $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
    }

    private function validate(){
    if (!$this->customer->login($this->request->post['email'], $this->request->post['password'])) {
    $this->error['message'] = $this->language->get('error_login');
    }

    if (!$this->error) {
    return TRUE;
    } else {
    return FALSE;
    }
    }
    }
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles