I tried checking all the names. It is working fine in php 5.3 but not working in php 5.5
An uncaught Exception was encountered
Type: RuntimeException
Message: C:\xampp\htdocs\project\application\models/Common_Model.php exists, but doesn't declare class Common_Model
Filename: C:\xampp\htdocs\project\system\core\Loader.php
Line Number: 306
Backtrace:
File: C:\xampp\htdocs\project\application\controllers\Auth.php Line: 7 Function: __construct
File: C:\xampp\htdocs\project\index.php Line: 292 Function: require_once
In the message, I can see an unexpected backslash in front of Common_Model.php
. Message: C:\xampp\htdocs\project\application\models/Common_Model.php exists, but doesn't declare class Common_Model
Common_Model.php
contains:
<? if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Common_Model extends CI_Model {
public function __construct()
{
// Call the CI_Model constructor
parent::__construct();
}
.
.
.
.
EDIT
I just changed Common_Model.php to Common_model.php and still getting the same error
An uncaught Exception was encountered
Type: RuntimeException
Message: C:\xampp\htdocs\project\application\models/Common_model.php exists, but doesn't declare class Common_model
Filename: C:\xampp\htdocs\project\system\core\Loader.php
Line Number: 306
Backtrace:
File: C:\xampp\htdocs\project\application\controllers\Auth.php Line: 7 Function: __construct
File: C:\xampp\htdocs\project\index.php Line: 292 Function: require_once
Your web server doesn't like php shorthand operator. Just change <?
to <?php
and it should be all good.
Try this
file name should be Common_model.php
and inside that
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Common_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
public function getUser()
{
# Your query goes here
}
}
In Controller
$this->load->model('Common_model'); # Load Model
$result = $this->Common_model->getUser(); # Access the model function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With