XK8ER
asked on
php - Call to a member function on a non-object
hello there,
I am getting this error (Call to a member function on a non-object)
I am able to render the captcha and see it on the webpage.. when I click on submit form it checks with ajax if all fields have text in it.. then if they do then it checks if the captcha was successfully entered or not by calling validate() and that's were I have the issue saying scoreResult() from ayah is non-object..
whats going on here I have tried maybe 100 different things for the past 5 hours with no luck.
I am getting this error (Call to a member function on a non-object)
I am able to render the captcha and see it on the webpage.. when I click on submit form it checks with ajax if all fields have text in it.. then if they do then it checks if the captcha was successfully entered or not by calling validate() and that's were I have the issue saying scoreResult() from ayah is non-object..
whats going on here I have tried maybe 100 different things for the past 5 hours with no luck.
require_once("ayah.php");
class field_captcha extends FormField
{
public function validate($value)
{
global $ayah;
$score = false;
$score = $this->ayah->scoreResult();
if ($score){
$score = true;
}
if (!$score) {
throw new FormFieldValidationException('incorrect_value');
}
return false;
}
public function render( array $params = null, Form $form = null )
{
$ayah = new AYAH();
$oldCaptcha = '<input type="hidden" name="captcha[value]" value="test123">';
$NewCaptcha = $ayah->getPublisherHTML();
return $oldCaptcha."\n\n".$NewCaptcha;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks hielo for being so helpful.. I get this now.
Fatal error: Call to a member function scoreResult() on a non-object in
this line
>>$score = $this->ayah->scoreResult() ;
Fatal error: Call to a member function scoreResult() on a non-object in
this line
>>$score = $this->ayah->scoreResult()
>>$NewCaptcha = $ayah->getPublisherHTML();
Needed to be changed as well:
$NewCaptcha = $this->ayah->getPublisherH TML();
Needed to be changed as well:
$NewCaptcha = $this->ayah->getPublisherH
You might want to post a new question about this. The instantiation of the object either failed or was not executed at all. As a result the ->method() notation caused the fatal error.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_9849-Making-CAPTCHA-Friendlier-with-PHP-Image-Manipulation.html