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

#1
[eluser]A_funs[/eluser]
Hi,

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()"

Code:
include_once('xxxxx/check.class.php');
protect("1, 2, 3");

I have also tried instantiating the class in the included file

Code:
include_once('xxxxx/check.class.php');
$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

#2
[eluser]Aken[/eluser]
What does your class file look like?

#3
[eluser]PhilTem[/eluser]
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?!

#4
[eluser]A_funs[/eluser]
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

#5
[eluser]PhilTem[/eluser]
How bout you replace the content of the file with something like

Code:
<?php

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

#6
[eluser]CroNiX[/eluser]
[quote author="A_funs" date="1342711564"]The classes are in a directory off the root folder, not within the codeigniter application directory.[/quote]
Code:
include_once('xxxxx/check.class.php');

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

Where are you including check.class.php from?

#7
[eluser]CroNiX[/eluser]
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.