Call to undefined method

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kaingo
Forum Newbie
Posts: 3
Joined: Wed Apr 28, 2010 6:48 pm

Call to undefined method

Post by kaingo »

Dear Gurus,

Please help I am a newbie to php. I am playing with snort and acid, I have got everything working but whenever I click a link I get the following message:

Call to undefined method ProtocolFieldCriteria::ProtocolFieldCriteria() in /usr/local/apache2/htdocs/acid/acid_state_citems.inc on line 979
The code where this occurs is as follows:

Code: Select all

function IPFieldCriteria($db, $cs, $export_name, $element_cnt)
    978    {
    979       parent::ProtocolFieldCriteria(&$db, &$cs, $export_name, $element_cnt,
    980                                     array("ip_tos"  => "TOS",
    981                                           "ip_ttl"  => "TTL",
    982                                           "ip_id"   => "ID",
    983                                           "ip_off"  => "offset",
    984                                           "ip_csum" => "chksum",
    985                                           "ip_len"  => "length"));
    986    }
Can someone please help. I have been at it now and some are saying I have to downgrade to PHP 4.3.4, I am using php-5.3.1 and I am new to php.

Thanks in advance.

Kaingo
Last edited by Benjamin on Wed Apr 28, 2010 7:26 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: Call to undefined method

Post by jraede »

What does the __construct() function look like for the class that that function comes from?
kaingo
Forum Newbie
Posts: 3
Joined: Wed Apr 28, 2010 6:48 pm

Re: Call to undefined method

Post by kaingo »

Hi jraede,

I ma very sorry for not responding soon to our reply. However this is the class statement I can get above the function

class IPFieldCriteria extends ProtocolFieldCriteria

Is that what you wanted to see?
I am getting the same error for all links I click on so if a fix is found for one I am sure this will solve all. Thanks for your effort

kaingo
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Call to undefined method

Post by social_experiment »

You are attempting to call a method that doesn't exist
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
phu
Forum Commoner
Posts: 61
Joined: Tue Mar 30, 2010 6:18 pm

Re: Call to undefined method

Post by phu »

In order for the code you posted to work, IPFieldCriteria must be a method on a class that extends a class that defines the method ProtocolFieldCriteria. parent:: notation will not work unless this is the case; some part of this equation is missing, but you did not provide enough code to know which.

Code: Select all

class ParentClass
{
    public function ProtocolFieldCriteria(...)
    { ... }
}

class SomeClass extends ParentClass
{
    public function IPFieldCriteria(...)
    {
        ...
        parent::ProtocolFieldCriteria(...);
        ...
    }
}
It looks like you may be using methods with the exact same name as classes... I'd assume that would work, but it's not a good idea from a readability standpoint, and if you're duplicating names across classes and methods, one or the other could definitely be more descriptive/accurate if you changed it.
kaingo
Forum Newbie
Posts: 3
Joined: Wed Apr 28, 2010 6:48 pm

Re: Call to undefined method

Post by kaingo »

Hi phu,

Thanks very much for your input. As I said, I am a newbie so let me digest this and try some of the tips especially looking at the syntax you provided. Can I post the whole code if I fail to correct this problem?
Thanks in advance

kaingo
PPowerHouseK
Forum Newbie
Posts: 1
Joined: Thu Jan 06, 2011 7:30 pm

Re: Call to undefined method

Post by PPowerHouseK »

Hey, I am having this same problem. What exactly needs to be changed to fix this:
Fatal error: Call to undefined method ProtocolFieldCriteria::ProtocolFieldCriteria() in acid_state_citems.inc on line 979
Post Reply