I have a little issue right now and its bugging me, hopefully one of you guys will be able to help me out.
Basically I'm creating a library to use in CodeIgniter and I'm getting this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Functions::$db
Filename: libraries/Functions.php
Line Number: 11
The Database library is already on autoload aswell as my functions library:
$autoload['libraries'] = array('database','session','encrypt','functions');
The Functions.php file is located in the application/libraries folder accordingly.
Line number 11 consists of this:
$this->db->where('username', $data);
Not sure as to why the db is an undefined property?
It's probably because you need to get the CI instance first since not everything is loaded yet:
$ci =& get_instance();
$ci->db->where('username', $data);
See if that helps. Also see the instructions here.
Related
whenever loading this
$this->load->library('database');
error is shown
Unable to load the requested class: database
without the above mentioned code,the following error is shown.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: LoginPage::$db
Filename: core/Model.php
Line Number: 52
Fatal error: Call to a member function select() on null in
C:\xampp\htdocs\Test_LR\application\models\Login_model.php on line 11
FIle permission From Filezilla...
Connect your FTP client to your web server. In FileZilla, right-click the "system" folder on your web server and choose File Permissions to open the file attributes. Type the correct number in the Numeric Value text field
This means CodeIgniter has a library database.
You can include libraries in two ways:
1) In application/config/autoload.php
Code:
$autoload['libraries'] = array('database'); // Include other libraries here like `session`.
2) Run time by using $this->load->library('database'); if not included with first method.
Without it, it will show fatal error.
Have you tried to use:
$this->load->database();
Instead of $this->load->library('database');
Or double check if your database file available on system
Sample example Usersmodel.php
class usersmodel extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
function examplefunction()
{
}
}
Since a couple of days I can't load a model in a codeigniter system anymore.
It gives the following error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Clients::$mdl_clients
Filename: controllers/clients.php
Line Number: 48
Controller code:
private function GetAllClients()
{
$this->load->model('clients_model', 'mdl_clients');
$clients = $this->mdl_clients->getClients()->result_array();
return $clients;
}
I read the codeigniter documentation again, and I'am not doing anything wrong that I'am aware of..
Can you guys help me out?
Change the model name by 'clients_model.php' if you dont have, and your class most name 'Clients_model'
It was a weird issue with my server. I uploaded everything to another, and it worked again
I'm developing a properties module for Expression Engine that's to take properties from Rightmove's BLM format and populate a database, and then those properties be searchable from the front-end.
I've found a CodeIgniter library (http://biostall.com/codeigniter-rightmove-blm-parser-library) that does the heavy lifting of the BLM files. However, I can't seem to load it.
My code in mcp.properties.php looks like this:
$config = array();
$this->EE->load->library('rightmove_v3_parser');
$this->rightmove_v3_parser->initialize($config);
$data['properties'] = $this->rightmove_v3_parser->process();
print '<pre>'; print_r($data['properties']); print '</pre>';
exit;
The library files are in a libraries sub-folder in my properties add-on folder under /system/expressionengine/third_party/.
However, when using the above code, I get the following error in Expression Engine:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Properties_mcp::$Rightmove_v3_parser
Filename: properties/mcp.properties.php
Line Number: 44
Fatal error: Call to a member function initialize() on a non-object in /Users/Martin/Sites/expressionengine/system/expressionengine/third_party/properties/mcp.properties.php on line 4
Where am I going wrong? Why can't I bundle this library with my add-on and call it within my add-on?
You've missed the EE object when referencing the library. So after loading the library you should use
$this->EE->rightmove_v3_parser
to access it, rather than
$this->rightmove_v3_parser
Have you included the library at the top of your plugin, i could be wrong but I don't think loading a library like that will work from a library subdir in your third_party plugin folder. Try including the library at the top of your plugin.
I have put the files I downloaded from http://www.openwall.com/phpass/ to application/libraries
In my controller, I am using this code -
$params = array(
'phpass_hash_strength' => 8,
'phpass_hash_portable' => FALSE
);
$this->load->library('PasswordHash', $params);
$password = $this->passwordhash->HashPassword($pwd);
I am getting these errors -
A PHP Error was encountered
Severity: Notice
Message: Uninitialized string offset: 3
Filename: libraries/PasswordHash.php
Line Number: 116
A PHP Error was encountered
Severity: Warning
Message: strpos() [function.strpos]: Empty delimiter
Filename: libraries/PasswordHash.php
Line Number: 116
Update
Removed PasswordHash.php, using SimpleLoginSecure now.
I had the same issue whilst integrating PasswordHash into Symfony2.
To solve it, I renamed the PasswordHash method to __construct.
In theory, PHP 5+ should look for a method with the same name as the class if it can't find a constructor (http://php.net/manual/en/language.oop5.decon.php). My guess is that the class name resolves differently once a namespace is added (a requirement for my integration), but I've not investigated at all.
I think your problem is you are trying to use a generic PHP object as a CodeIgniter library. You can't just do that. You'll need to modify the original code to work, or download one of the contributed libraries already designed for CodeIgniter.
CodeIgniter libraries have some restrictions (such as how they are instantiated), so just dropping any file into the libraries folder won't work.
I have been trying to implement an auth system for Codeigniter. I wanted to save time, though it hasn't succeeded so far.
The system I'm trying to implement is: http://codeigniter.com/wiki/auth/
Currently I have some forms working, but the registration form generates a fatal error:
PHP Fatal error: Call to undefined method CI_Loader::setdata() in /Applications/MAMP/htdocs/CI+Login/system/application/controllers/auth.php on line 159
Anyone has an idea what that is about? Anyone has got this system running?
thx.
EDIT:
The code that generates the error is:
if ($this->config->item('auth_use_security_code'))
$this->authlib->register_init();
$data['countries'] = $this->Usermodel->getCountries();
$this->load->setdata($data);
The problem is that load does not contain a method named setdata, has it in a previous version of CI or what can I make of this?
Try this:
$this->load->vars($data);
or remove this line and use the second parameter of the $this->load->view() function.
$this->load->view($this->config->item('auth_register_view'),$data);