0

Hi I'm making a webpage to get phone number from registerer and make random number as a pin number to save in DB. and I want to show registerer to enter the random number.

So I made these code.

class RegistersController extends AppController{

    public function index()
    {
        $random = rand(11111,99999);
        $register = $this->Registers->newEntity($this->request->data);
        if($this->Registers->save($register)) {
            $this->Flash->success('The Phone number has been sent.');
            $reg = $this->Registers->patchEntity($random);
            $this->Registers->save($reg);
            return $this->redirect(['action' => 'certnum']);
        }
        $this->set(compact('register'));
    }
}

But somehow It makes fatal error which I have no idea what to do?

Do i have to the random number into array with certain id number or something?

Please help.

Thank you

4

1 回答 1

5

回到开发者学校:在寻求帮助和描述问题时,请务必发布完整的错误消息、任何警告、通知、堆栈跟踪和其他相关的调试输出。

我不知道的错误消息与您尝试将无效数据类型传递给patchEntity()的事实有关。它需要一个数组,您传递的是一个整数,因为这是 rand() 生成的。将整数放入您期望的任何数组结构中,它应该可以工作。

于 2014-12-04T14:00:40.303 回答