views:

108

answers:

1

Hey, so I'm coding a php application, and I've run into an error, which I am for some reason not seeing (me being really bad at coding and lack of sleep may have something to do with it.

Anyway, here's my tricky problem :)

Parse error: syntax error, unexpected $end, expecting T_FUNCTION

and the code:

The model

class Model_DbTable_Users extends Zend_Db_Table_Abstract
{
    protected $_name = 'users';

    public function addUser($username, $password, $email)
    {
        $data = array( 'username' => $username,
                       'password'    => $password,
                       'email'    => $email);
        $this->insert($data);
    }

and the action

public function stage1Action()
{
    $form = new Form_RegisterForm;
    $this->view->form = $form;

    $request = $this->getRequest();
    #if the form is submitted
    if($request->isPost()){
        #validated automatically by the form-errors echoed if invalid
        if($form->isValid($this->_request->getPost())) {
            $username = $form->getValue('username');
            $password = $form->getValue('password');
            $email = $form->getValue('email');

            $users = new Model_DbTable_Users;
            $users->addUser($username, $password, $email);

            $this->_helper->redirector('stage2');
        }
    }
}

I get this action after pressing the submit button.

Any help greatly appreciated. Thanks in advance

+1  A: 

It looks like you aren't putting () on the end of your class names when you instantiate a class. Change this:

$form = new Form_RegisterForm;

to this

$form = new Form_RegisterForm();

Do the same thing for Model_DbTable_Users.

Hope this helps!

mattbasta
am I meant to? I thought that was just for functions. . . I'm very new to this you see
Max Bucknell
Yes. When you create a new instance of a class, you put parentheses at the end. This lets you use a constructor. I.e.: $me = new person("mattbasta");Having empty parentheses tells the interpreter that you're only looking to use the default constructor.
mattbasta