Runescape Community: [Answered] Php Error: Call To Undefined Method - Runescape Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Answered] Php Error: Call To Undefined Method

#1 User is offline   Five Aces

  • "You win again, gravity!"
  • Icon
  • Group: Honored Member
  • Posts: 7928
  • Joined: 20-December 03
  • RS Name:Five Aces
  • RS Status:Inactive
  • Clan:Team Cool

Posted 09 November 2009 - 06:43 AM

So I am filling in my spare time by following poorly documented tutorials to expand my PHP understanding. (A text book would be most excellent, but I have not had any time to go looking for one.) At any rate, while playing around with this particular tutorial, I get the same error, again and again. Some rudimentary thinking on my behalf has determined that I have no idea how to go about rectifying my problem, here. :-(

Exact error message:
Call to undefined method System::getsettings() in C:\xampp\htdocs\TEST\includes\db.php on line 16


This is in reference to me calling the getSettings() function that exists in the System class in system.php. I'm probably using some horribly incorrect syntax, or some such simple error, but it is beyond me.

The files in question (they exist in the same directory):

system.php
Spoiler


db.php
Spoiler


Any and all help is, as always, much appreciated! :-)
"It has always been the prerogative of children
and half-wits to point out that the emperor has no clothes.
But the half-wit remains a half-wit,
and the emperor remains an emperor."
Posted Image
0

#2 User is offline   stategamer

  • Member
  • Icon
  • Group: Member
  • Posts: 457
  • Joined: 17-September 06
  • RS Name:stategamer
  • RS Status:Member

Posted 09 November 2009 - 06:50 AM

if u look in the first file ur not escaping ur '.
And when u look at the colours ull see its going wrong somewhere :P


i see u edit-ed it, are u still getting the problem?


oh and i believe u can only use "::" on static functions.


oh and did u try using 'public,private,static,protected' ?



Quote

try doing this :
//load settings as defined in the System class (system.php)
$settings = System::getSettings();


change that into :

//load settings as defined in the System class (system.php)
$settings = System->getSettings();

This post has been edited by stategamer: 09 November 2009 - 07:18 AM

Posted Image
0

#3 User is offline   Five Aces

  • "You win again, gravity!"
  • Icon
  • Group: Honored Member
  • Posts: 7928
  • Joined: 20-December 03
  • RS Name:Five Aces
  • RS Status:Inactive
  • Clan:Team Cool

Posted 09 November 2009 - 07:19 AM

View Poststategamer, on 09 November 2009 - 10:50 PM, said:

if u look in the first file ur not escaping ur '.
And when u look at the colours ull see its going wrong somewhere :P


i see u edit-ed it, are u still getting the problem?


oh and i believe u can only use "::" on static functions.


oh and did u try using 'public,private,static,protected' ?

Yeah, I edited out the password, but used the word "it's", which threw out the code (at least the colouring). Only noticed after I posted. :-S

I'm still getting the problem.

How would I make that a static function? (Will Google, in the meantime.)


e: Mkay, went to the php.net page concerning such matters, and only confused myself more. Adding static or public (or both) to the function did not change my error.

Also, changing to that arrow cause me to get a parse error instead. :-(


e2: Swapping out System::getSettings(); for parent::getSettings(); returns the same error message. (i.e. "System::getsettings()" is still undefined.) At the very least, it tells me it's having no trouble accepting that System exists (not that I needed any extra proof - it wouldn't get past the "extends" line if that was the problem), it just refuses to believe that getSettings() is a valid function... :-(
"It has always been the prerogative of children
and half-wits to point out that the emperor has no clothes.
But the half-wit remains a half-wit,
and the emperor remains an emperor."
Posted Image
0

#4 User is offline   No1 1000

  • It's "No One."
  • Icon
  • Group: Senior Moderator
  • Posts: 11361
  • Joined: 22-July 03
  • RS Name:No1 1000
  • RS Status:Inactive

Posted 09 November 2009 - 08:13 AM

    //load settings as defined in the System class (system.php)
    $settings = System::getSettings();


$this->getSettings();

or if it's static, perhaps this::getSettings().


Or you could just copy the method and values over to the DB class, and scratch the whole extends bit.
Posted Image"The most savage controversies are those about matters as to which there is no good evidence either way."
- Bertrand Russell [Confirmation Bias]
0

#5 User is offline   Five Aces

  • "You win again, gravity!"
  • Icon
  • Group: Honored Member
  • Posts: 7928
  • Joined: 20-December 03
  • RS Name:Five Aces
  • RS Status:Inactive
  • Clan:Team Cool

Posted 09 November 2009 - 08:37 AM

Found my issue.

I decided to remove the whole "call one class file into the other" thing, because I suspected it was more to do with properly locating the parent class. How best to explain is beyond me, but I know that when I changed the name of the class being extended to something that didn't exist, I got an error message. So I cut the crap, and pasted it straight in.

And, of course, it worked the first time.

Having found my issue - the "require_once" function - it was only a few seconds until I had my answer in front of me. Even though I was calling the file into a file that coexisted in the same directory, it was all taking place in another file in yet another directory. (Basically, I have two folders in a directory. The two class files were in one, and the script calling them was in another.) As a result, the "require_once" command was trying to find it in the wrong directory - I had wrongfully assumed that the command would search where the file was located, not where the file was being called.

Thanks for the help, though!

^_^

(Just found this, which sums it up nicely: http://ca3.php.net/m...quire.php#87191 )
"It has always been the prerogative of children
and half-wits to point out that the emperor has no clothes.
But the half-wit remains a half-wit,
and the emperor remains an emperor."
Posted Image
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Forums Directory