English 中文(简体)
php错误: 要求从Array(Array)获得成员非目标的职能
原标题:php error: Call to a member function fromArray() on a non-object

I am trying to set up a "forgot password" system. User enters email and if it exists a new email is recorded and sent to the user email address entered. The user email check works ok. When trying to enter a new passord into system it does not.

该法典是:

..... (form is_valid and check email ok)

if(is_object($object)) {

        $newpassword = substr(str_shuffle(str_repeat( ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ,8)),0,8);

        $input = $form->getValues();

        $user = Doctrine::getTable( Tcc_Model_User )
            ->find($input[ email ]);

        $user->fromArray($input);
        $user->Password = md5($newpassword);
        $user->save();
......
email send

} else {
    $form->getElement( email )->addError( Sorry, there is no record of that email adddress. );
  }

我发现的错误是:

Call to a member function fromArray() on a non-object

难道有人能帮助我看一看我做什么错了? 请

最佳回答

Simply put, $user is not an object. It s probably either false or null, signifying that find() did not actually find what it was looking for.

您可以看到,<代码>用户实际上是var_dump($user),然后请读到find的文件,以了解它为什么会回来。

问题回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签