dpa31905 2009-11-21 14:34
浏览 25

Zend Framework用户注册 - 添加到db

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条回答 默认 最新

  • dongqiao1151 2009-11-22 21:52
    关注

    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!

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么