Cannot instantiate non-existent class: |
[eluser]Heatherita[/eluser]
Hi, I'm using CI with Red Hat 9 and PHP 4.2.2. There is no way to change this for the time being (though I'd love to). I can basically squeak by, but am having some problems loading one model in particular. I get the above error: "Fatal error: Cannot instantiate non-existent class: authuser in /var/www/html/webapp/codeigniter_pc/system/libraries/Loader.php on line 177" when I try to load the following model: Is there anything blatantly wrong with this code in php 4.2.4? <?php class AuthUser extends Model { function AuthUser() { // Call the Model constructor parent::Model(); } public function authenticate() { $this->myuser = array(); $mycompany = $this->load->helper('mycompany'); $this->servicedb = $this->load->database('service', TRUE); //$myuser = array(); $encryptedpw = encrypt_pw($this->myuser['plainpw']); $store = get_store_number(); if ( ($store == '555') || ($store == '777')) { $store = '070'; } $query = " SELECT stuff from a db... "; // print ("query is " . $query . "<br>"); $query = $this->servicedb->query($query); log_message('debug',"num rows is " . $query->num_rows() . "<br>"); $row = $query->row(); //print " ".odbc_error(); //print " ".odbc_errormsg(); $this->myuser['autflg'] = $row->AUTFLG; $this->myuser['username'] = rtrim($row->FNAM."".$row->LNAM); $this->myuser['pw'] = $row->PASSWRD; $this->myuser['id'] = $row->USERID; $this->myuser['job'] = $row->JOB; log_message('info',"autflg is " . $this->myuser['autflg']); log_message('info',"username is " . $this->myuser['username']); log_message('info',"pw is " . $this->myuser['pw']); log_message('info',"id is " . $this->myuser['id']); log_message('info',"job is " . $this->myuser['job']); //print("<pre>"); //print_r($myuser); //print("</pre>"); } public function getValue($name) { if (!array_key_exists($name,$this->myuser)) return ''; log_message('info',"value for " . $name . " is " . $this->myuser[$name]); return $this->myuser[$name]; } public function setValue($name,$value) { $this->myuser[$name] = $value; } } ?>
[eluser]Jamie Rumbelow[/eluser]
I think so. You're on PHP4, and I think that the public and private statements came in at PHP5.
[eluser]Seppo[/eluser]
[quote author="Heatherita" date="1212114848"]Hi, I'm using CI with Red Hat 9 and PHP 4.2.2. There is no way to change this for the time being (though I'd love to).[/quote] Do you know that CI requires PHP 4.3.2 or higher ?
[eluser]Heatherita[/eluser]
Hi, Yes, I am aware. Like I said I'm just squeaking by, keeping my fingers crossed...."livin' on a prayer", as Jon Bon Jovi would say..... Heather
[eluser]wiredesignz[/eluser]
Your class name is wrong: Authuser or make it Auth_user. And set filename to match. CI expects ucfirst class names only.
[eluser]Heatherita[/eluser]
thanks wiredesignz. Missed that in the docs, which I assure you I am reading in between working on code, chatting with my co-workers, finalizing my divorce, taking care of my kids, selling my house, trying on naughty lingerie, etc etc.
[eluser]wiredesignz[/eluser]
lol, got pics of the latter? Welcome to the forums.
[eluser]Heatherita[/eluser]
Hi! OK, I'd been getting 404's all morning, after ucfirst-ing the name of the model, removing "public" and "private" before model methods, etc. In fact, it was looking like I couldn't access any url other than the "default controller" that I'd specified in config.php. Finally, I found the solution in my .htaccess file: ("before" version) <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / #Removes access to the system folder by users. #Additionally this will allow you to create a System.php controller, #previously this would not have been possible. #'system' can be replaced if you have renamed your system folder. RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php/$1 [QSA,L] #Checks to see if the user is attempting to access a valid file, #such as an image or css document, if this isn't true it sends the #request to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] </IfModule> I had to remove the "RewriteBase" line, and add "?" in the RewriteRule lines, so now it looks like this: ("after" version) <IfModule mod_rewrite.c> RewriteEngine On #Removes access to the system folder by users. #Additionally this will allow you to create a System.php controller, #previously this would not have been possible. #'system' can be replaced if you have renamed your system folder. RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [QSA,L] #Checks to see if the user is attempting to access a valid file, #such as an image or css document, if this isn't true it sends the #request to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [QSA,L] </IfModule> Now it works great. I can access my controllers using the standard convention hostname/controller/method/ So happy! Thanks so much to everyone! Can't wait to really get going with CodeIgniter! I used Java Struts a few years ago and really liked it.... Heather |
Welcome Guest, Not a member yet? Register Sign In |