Welcome Guest, Not a member yet? Register   Sign In
Cannot load ANY custom libraries
#1

[eluser]Ludatha[/eluser]
For some reason it seems that my previous issue is not just with the libraries I downloaded, but with the custom ones I create.

This is my current site
http://ludatha.com/php/

As you can see it has an error, every time I use a custom library it will throw this error, just with different line numbers and variables.

Can someone help me? I have tried for ages trying to fix this and even my friend doesn't know.

My Files

welcome.php
Code:
<?php

class Welcome extends Controller {

    function Welcome(){
         parent::Controller();
         $this->load->library("Ludathaauth");
     }
     function index(){
         $this->Ludathaauth->login();
    }
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */

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

class Ludathaauth {
    function login()
    {
        echo "chicken";
    }
}

?>


The error is:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Welcome::$Ludathaauth
Filename: controllers/welcome.php
Line Number: 10

Fatal error: Call to a member function login() on a non-object in /home/ludatha/public_html/php/system/application/controllers/welcome.php on line 10
#2

[eluser]madeks[/eluser]
I guess you knew these already but to ensure it:

1. What is your library file name? I guess it should be "Ludathaauth.php" (start with Capital letter)?

2. Did you put it in the correct path, like "app/libraries/"?
#3

[eluser]Dam1an[/eluser]
Also when you call it in index, it should be lowercase (although I doubt that will make a difference as I think PHP is case insensitive)
#4

[eluser]Evil Wizard[/eluser]
you're almost right Dam1an php is case insensitive when it comes to class and method/function names
Code:
class MY_CLASS {
    public $lower_case;
    public $UPPER_CASE;
    public function __construct()
    {
        echo __CLASS__;
    }
    public function lowercase()
    {
        // do something
    }
    public function UPPERCASE()
    {
        // do something
    }
}
// because of class name case insensitivity this line works
$objSelf = new my_class();
// because of method name case insensitivity these lines works
$this->LOWERCASE();
$this->lowercase();
// and these
$this->uppercase();
$this->UPPERCASE();
// but because variable names are case sensitive these lines generate warnings
echo $this->LOWER_CASE;
echo $this->upper_case;
#5

[eluser]Ludatha[/eluser]
Quote:[quote author="madeks" date="1244059657"]I guess you knew these already but to ensure it:

1. What is your library file name? I guess it should be "Ludathaauth.php" (start with Capital letter)?

2. Did you put it in the correct path, like "app/libraries/"?

All file names are correct (I've checked thousands of times) (Yes it is Ludathaauth.php)



It is in the correct path, because it does load the library, just when I try to use it I get the error.[/quote]

I have fixed my problem!

I need to change the name to lower-case even though it was supposed to be uppcase...

Code:
class Welcome extends Controller {

    function Welcome(){
         parent::Controller();
         $this->load->library("ludathaauth");
     }
     function index(){
         $this->ludathaauth->login();
    }
}
#6

[eluser]Dam1an[/eluser]
Try creating a local object using the library
Code:
include(APPPATH.'libraries/Ludathaauth.php');
$test = new Ludathaauth();
$test->login();




Theme © iAndrew 2016 - Forum software by © MyBB