Loading custom library

#11
[eluser]noideawhattotypehere[/eluser]
This is how i load my custom google analytics library:
$this->load->library('analyticsapi');
./application/libraries/analyticsapi.php [notice its lowercase! it didnt work when it was uppercase]

class AnalyticsApi {
//rest of the code.

#12
[eluser]mzvasiq[/eluser]
Still I get the same error ..

Severity: Notice --> Undefined property: Login_Controller::$BlogUtilities /Applications/MAMP/htdocs/MzBlog/application/controllers/login_controller.php 21

Line no 21: Is calling a function

And yeah the Library file name is written in the format according the CodeIgniter's rule....

#13
[eluser]davidMC1982[/eluser]
In the log, does it actually say:

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

Or

Code:
No direct script access allowed

If the former, then your library file is probably not being parsed as php. Maybe you've missed the opening <?php tag or your file name is acutally *.php.* If in Windows, remove the tick from "Hide extensions for known filetypes" in your folder options. If it's not these two things, then you should post the complete controller and library code. You're asking us to hit an invisible target otherwise.

If it displays the latter ('No direct script access allowed') then your code has somehow unset the BASEPATH constant or you're not calling it through the framework. Again, we'd need to see the code to have any idea of how this may have occurred.

#14
[eluser]mzvasiq[/eluser]
Ok this is the code for BlogUtilities.php. And regarding the file extension i'm using Mac so the Type of file says 'Php'

BlogUtilities.php

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

class BlogUtilities {
  function f1(){
    ....code
   }

  function f2(){
  .....code
  }

}

Login_Controller.php

Code:
class Login_Controller extends CI_Controller{

function index(){
  $this->load->view('Login');
}

function validate_user($username, $password){
  $this->load->model('DBQuery_Model');
  $user_attr = $this->DBQuery_Model->retrieve_user_attr($username);

  if($user_attr['account_status'] == 'Active'){
  
   $this->load->library('BlogUtilities');
   $hash_pass = $this->BlogUtilities->generate_hash($password);
   $mixed_salt_hash = $this->BlogUtilities->mix_hash_salt($hash_pass, $user_attr['salt']);
  
  
  }
}

}

And yeah the exact Error which i'm getting in the Log file is this ....

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

ERROR - 2013-10-09 16:31:01 --> Severity: Notice  --> Undefined property: Login_Controller::$BlogUtilities /Applications/MAMP/htdocs/MzBlog/application/controllers/login_controller.php 21

Line No 21 being loading the BlogUtilities.php file

#15
[eluser]scornaky[/eluser]
Code:
$this->blogutilities->f1();

Quote:Once loaded you can access your class using the lower case version:
$this->someclass->some_function(); // Object instances will always be lower case

Code:
$hash_pass = $this->blogutilities->generate_hash($password);
   $mixed_salt_hash = $this->blogutilities->mix_hash_salt($hash_pass, $user_attr['salt']);

#16
[eluser]mzvasiq[/eluser]
Oh finally... it got solved
Thanks a lot all of you for your help....

#17
[eluser]scornaky[/eluser]
to say or not to saySmile

Have u read my first post?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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