• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Functions from external classes not working


So I am trying to use some external classes for my login system. The classes are in a directory off the root folder, not within the codeigniter application directory. Using the following code I get this message - the include resolves fine but for some reason the function won't run:

"Fatal error: Call to undefined function protect()"

protect("1, 2, 3");

I have also tried instantiating the class in the included file

$login = new Check();

This returns an error saying the class is not defined. Both the class and function are clearly defined in the included file...Thanks for your help

What does your class file look like?

It will work with including other classes if you include them correctly. And from what you're saying it's a wrong path that you're using in include Wink

Maybe you wanna try an absolute path instead of a relative one?!

tried both absolute and relative, I am pretty sure the file is being included though, since I tried a dummy filename and received an error saying the standard "cannot open stream" - which I am not getting when I include the file.

I will post the class soon

How bout you replace the content of the file with something like


die('here we are');

and see if it works?

If you will see the output 'here we are' it's at least not a problem of not finding the file but something within the class.

Oh, btw: Does the file have a closing PHP-tag at the end? Don't think this is the problem, but may be - and CI recommends not using closing tags Wink

[quote author="A_funs" date="1342711564"]The classes are in a directory off the root folder, not within the codeigniter application directory.[/quote]

assumes xxxxx is at the same level as index.php.

Where are you including check.class.php from?

And personally, I'd turn your code into a library that integrates with CI so you can use its loader, sessions, database, and everything else.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.