Welcome Guest, Not a member yet? Register   Sign In
Loading custom library
#1

[eluser]mzvasiq[/eluser]
I created a Custom Library and saved it in application/libraries folder. But when i try to load the library from the Controller using the following code.

Code:
$this->load->library('BlogUtilities');

It just doesn't get loaded, so after checking the CodeIgniter's log file I came to know it's giving 'No direct script access allowed'

I don't understand why am i getting this error.

My Library has only two functions in it.
#2

[eluser]scornaky[/eluser]
Check:
file name it is in libraries folder
filename is BlogUtilities.php
class name is BlogUtilities

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');


class BlogUtilities
{

public function test()
{
    echo "time now".time();
}

}

call
Code:
$this->load->library('BlogUtilities');
$this->blogutilities->test();
#3

[eluser]mzvasiq[/eluser]
Ya it's exactly the same, i crossed checked everything. I don't know why I'm still getting that error.

There's no .htaccess file in the folder, is it due to that ?

#4

[eluser]scornaky[/eluser]
in libraries?
I don`t have this kind of thing thereSmile.

But.. i`m saying again : filename is .php ? Not "BlogUtilities.php.txt"

Take a look in your host or in windows : view extensionSmile

"blogutilities" name is lowercase ? - in call
#5

[eluser]mzvasiq[/eluser]
Yea filename is in .php extension.

And yes even the Filename is being called correctly....

#6

[eluser]scornaky[/eluser]
make a test: use in autoload

Code:
$autoload['libraries'] = array('blogutilities');  //to check
then call
Code:
$this->blogutilities->test();

is working?

#7

[eluser]mzvasiq[/eluser]
I had tried that too... even that's not working

In the log it says

Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
#8

[eluser]scornaky[/eluser]
[quote author="mzvasiq" date="1381324972"]I had tried that too... even that's not working

In the log it says

Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
[/quote]

what you type in URL in browser?
#9

[eluser]mzvasiq[/eluser]
I don't type anything in the browser. There's a function in my Controller which loads this Library and calls the function directly.

#10

[eluser]scornaky[/eluser]
yes Smile...
And your controller extend extends CI_Controller ?

Code:
class MY_Controller extends CI_Controller { }

or try this:

Code:
$this->CI =& get_instance();
$this->CI->load->library('blogutilities');




Theme © iAndrew 2016 - Forum software by © MyBB