Fatal error: Cannot redeclare class My_connection in C:\wamp\www\mvc\smsc\application\models\my_connection.php on line 38
I created a model My_connection. I am calling this method into the constructor of my controller. Every error has meaning. What is the reason behind that error. Please, tell the meaning of error. What can be cause. I have read out the many question relating to this. All questions and their answer somewhat different. They try to correct the code. I want to know the reason. Please, help relative to question.
<?php
class My_connection extends CI_Model{
public function __construct(){
parent::__construct();
}
public function is_connected(){
$session_id=$this->session->userdata('session_id');
$session_username=$this->session->userdata('username');
$session_password=$this->session->userdata('password');
$this->db->select('session_id');
$this->db->from('ci_sessions');
$this->db->where('session_id',$session_id);
$ses_query=$this->db->get();
if($ses_query->num_rows>0){
foreach($ses_query->rows as $row){
$session_db_id=$ses_query->row();
}
}
$this->db->select('username','password');
$this->db->from('users');
$this->db->where('username',$session_username);
$user_query=$this->db->get();
if($user_query->num_rows()>0){
foreach($user_query->result() as $row){
$password=$row->password;
$username=$row->username;
}
}
if( md5($password)==$session_password AND $username==$session_username AND $session_db_id==$session_id){
return TRUE;
}
else {
return FALSE;
}`enter code here`
}
}
/**
* End of file my_connection.php
* Location: application/models/my_connection.php
*/`
Last line is 38. According to error. I have no understanding to solve it.
Namespace
if you really want to keep the name the same...but changing the name is easiest!class My_connection
--declared more than once.