在第303行的C:\ wamp \ www \ system \ core \ Loader.php中找不到类

时间:2015-03-26 07:21:44

标签: php codeigniter wamp

好的,我是PHP的新手,所以我恳请你理解。 我已经提出了我的新申请,但我无法弄清楚为什么会抱怨。我得到了非常奇怪和奇怪的错误

    db->query($sql); 
    if ($query->num_rows() > 0) { 
       $row = $query->row(); 
       foreach ($row as $key => $val) {
          $this->$key = $val; 
       } 
       return $row; 
    } 
    return null; 
} 

function getUser($info=NULL, $active=NULL) { 
    $sql = "SELECT * FROM tv_user WHERE 1 = 1 "; 
    if (!is_null($info)) { 
        if (empty($info->username) || empty($info->password)) { 
            return null; 
        } 
        if (!empty($info->username)) { 
            $sql .= " AND (username = '{$info->username}' OR email = '{$info->username}' OR id = '{$info->username}') ";
        }
        if (!empty($info->password)) { 
            $sql .= " AND password = '".md5($info->password)."' ";
        } 
    }
    if (!empty($active)) { 
        $sql .= " AND active = '{$active}' "; 
    }
    $query = $this->db->query($sql); 
    if ($query->num_rows() > 0) { 
        $row = $query->row(); 
        foreach ($row as $key => $val) { 
            $this->$key = $val; 
        } 
        return $row; 
    } 
    return null; 
}

function getUsers($active=NULL) { 
    $sql = "SELECT * FROM tv_user WHERE 1 = 1"; 
    if (!empty($active)) { 
        $sql .= " AND active = '{$active}'"; 
    }
    $query = $this->db->query($sql); 
    return $query->result(); 
}

function isUserExist($username=NULL, $active=NULL) { 
    $sql = "SELECT * FROM tv_user WHERE 1 = 1 "; 
    if (!empty($username)) { 
        $sql .= " AND username = '{$username}' "; 
    } 
    if (!empty($active)) { 
        $sql .= " AND active = '{$active}' "; 
    } 
    $query = $this->db->query($sql); 
    return ($query->num_rows() > 0); 
} 

function getUserByEmail($email, $active=NULL) { 
    if (empty($email)) { return null; } 
    $sql = "SELECT * FROM tv_user WHERE email = '{$email}' "; 
    if (!empty($active)) { 
        $sql .= " AND active = '{$active}' "; 
    } 
    $query = $this->db->query($sql); 
    if ($query->num_rows() > 0) { 
        $row = $query->row(); 
        foreach ($row as $key => $val) { 
            $this->$key = $val; 
        } 
        return $row; 
     } 
     return null; 
} 

function getSocialUser($uid=NULL, $provider,$email=NULL, $active=NULL) {
    if (empty($provider)) { return null; } 
    $sql = "SELECT * FROM tv_user WHERE 1 = 1 "; 
    if (!empty($uid)) { $sql .= " AND uid = '{$uid}' "; } 
    if (!empty($email)) { $sql .= " AND email = '{$email}' "; } 
    $sql .= " AND provider='{$provider}'"; 
    if (!empty($active)) { $sql .= " AND active = '{$active}' "; } 
        $query = $this->db->query($sql); 
        if ($query->num_rows() > 0) { 
            $row = $query->row(); 
            foreach ($row as $key => $val) { 
                $this->$key = $val; 
            } 
            return $row; 
         } 
     return null; 
}

function uuid() { 
    return strtoupper(substr(dechex(time()).dechex(mt_rand(1,65535)), 0, 6)); 
} 

function add($data) { 
    return $this->db->insert("tv_user", $data); 
} 

function update($data, $where) { 
    return $this->db->update("tv_user", $data, $where); 
}

function delete($where) { 
    return $this->db->delete("tv_user", $where); 
}

function login($username, $password) { 
    if (empty($username) || empty($password)) { 
        return FALSE; 
    }
    $password = md5($password); 
    $sql = "SELECT * FROM tv_user WHERE username='{$username}' AND password='{$password}' AND active=1"; 
    $query = $this->db->query($sql); 
    if ($query->num_rows() > 0) { 
        $user = $query->row(); 
        $user_data = array(); 
        foreach($user as $key => $val){ 
            $user_data[$key] = $val; 
        } 
        $user_data["login"] = TRUE; 
        $this->session->set_userdata('user', $user_data); 
        if ($user->user_type == USR_ROOT) { 
            $this->session->set_userdata('root_addmin_logged_in', TRUE); 
            $this->session->set_userdata('addmin_logged_in', TRUE); 
        } else 
            if (in_array($user->user_type,array(USR_ADMIN, 
                                                USR_MODERATOR, 
                                                USR_TOUR, 
                                                USR_HOTEL, 
                                                USR_FLIGHT, 
                                                USR_VISA)
                )) 
             { 
                  $this->session->set_userdata('root_addmin_logged_in', FALSE); 
                  $this->session->set_userdata('addmin_logged_in', TRUE);
             } else { 
                  $this->session->set_userdata('root_addmin_logged_in', FALSE); 
                  $this->session->set_userdata('addmin_logged_in', FALSE); 
             } 
             $this->session->set_userdata('logged_in', TRUE);
             $this->session->set_userdata('logged_user', $user); 
             return TRUE; 
         } 
         return FALSE; 
     } 

     function logout() { $this->session->sess_destroy(); } 

      function verify_reset_password_code($email, $code) { 
          if (empty($email) || empty($code)) { 
              return FALSE; 
          } 
          $sql = "SELECT * FROM tv_user WHERE email = '{$email}' "; 
          $query = $this->db->query($sql); 
          if ($query->num_rows() > 0) { 
              $row = $query->row(); 
              return ($code == md5(SITE_NAME.$row->fullname))? TRUE : FALSE; 
          } else { 
              return FALSE; 
          } 
      }
 } 
?> 

被解释为

PHP Fatal error:  Class 'M_user' not found in C:\wamp\www\system\core\Loader.php on line 303

enter image description here

因为我是新人,所以我不是很好。我不得不说我在WAMP下运行我的应用程序。它可能是微不足道的,但我不能得到它。

我甚至在autoload.php文件中包含了所有模块,如下所示:

$autoload['model'] = array(
'm_user',
'm_user_online',
'm_content_category',
'm_content',
'm_nation',
'm_mail',
'm_message',
'm_feedback',
'm_photo',
'm_tour',
'm_tour_rate',
'm_tour_departure',
'm_tour_departure_rate',
'm_tour_itinerary',
'm_tour_category',
'm_tour_activity',
'm_tour_destination',
'm_tour_tripnote',
'm_tour_request',
'm_visa',
'm_visa_tips',
'm_question',
'm_hotel',
'm_room',
'm_room_rate',
'm_album_category',
'm_album',
'm_tour_option_category'

);

提到它的部分代码:

    // --------------------------------------------------------------------

/**
 * Model Loader
 *
 * This function lets users load and instantiate models.
 *
 * @param   string  the name of the class
 * @param   string  name for the model
 * @param   bool    database connection
 * @return  void
 */
public function model($model, $name = '', $db_conn = FALSE)
{
    if (is_array($model))
    {
        foreach ($model as $babe)
        {
            $this->model($babe);
        }
        return;
    }

    if ($model == '')
    {
        return;
    }

    $path = '';

    // Is the model in a sub-folder? If so, parse out the filename and path.
    if (($last_slash = strrpos($model, '/')) !== FALSE)
    {
        // The path is in front of the last slash
        $path = substr($model, 0, $last_slash + 1);

        // And the model name behind it
        $model = substr($model, $last_slash + 1);
    }

    if ($name == '')
    {
        $name = $model;
    }

    if (in_array($name, $this->_ci_models, TRUE))
    {
        return;
    }

    $CI =& get_instance();
    if (isset($CI->$name))
    {
        show_error('The model name you are loading is the name of a resource that is already being used: '.$name);
    }

    $model = strtolower($model);

    foreach ($this->_ci_model_paths as $mod_path)
    {
        if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
        {
            continue;
        }

        if ($db_conn !== FALSE AND ! class_exists('CI_DB'))
        {
            if ($db_conn === TRUE)
            {
                $db_conn = '';
            }

            $CI->load->database($db_conn, FALSE, TRUE);
        }

        if ( ! class_exists('CI_Model'))
        {
            load_class('Model', 'core');
        }

        require_once($mod_path.'models/'.$path.$model.'.php');

        $model = ucfirst($model);

        $CI->$name = new $model();

        $this->_ci_models[] = $name;
        return;
    }

    // couldn't find the model
    show_error('Unable to locate the model you have specified: '.$model);
}

这是我的m_user.php类:

<?
      class M_User extends CI_Model
      {
       function load($id)
        {
        $sql   = "SELECT * FROM tv_user WHERE id = '{$id}' ";
        $query = $this->db->query($sql);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            foreach ($row as $key => $val) {
                $this->$key = $val;
            }
            return $row;
        }
        return null;
    }

    function getUser($info=NULL, $active=NULL)
    {
        $sql   = "SELECT * FROM tv_user WHERE 1 = 1 ";
        if (!is_null($info)) {
            if (empty($info->username) || empty($info->password)) {
                return null;
            }
            if (!empty($info->username)) {
                $sql .= " AND (username = '{$info->username}' OR email = '{$info->username}' OR id = '{$info->username}') ";
            }
            if (!empty($info->password)) {
                $sql .= " AND password = '".md5($info->password)."' ";
            }
        }

        if (!empty($active)) {
            $sql .= " AND active = '{$active}' ";
        }

        $query = $this->db->query($sql);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            foreach ($row as $key => $val) {
                $this->$key = $val;
            }
            return $row;
        }
        return null;
    }

    function getUsers($active=NULL)
    {
        $sql   = "SELECT * FROM tv_user WHERE 1 = 1";
        if (!empty($active)) {
            $sql .= " AND active = '{$active}'";
        }

        $query = $this->db->query($sql);
        return $query->result();
    }

    function isUserExist($username=NULL, $active=NULL)
    {
        $sql = "SELECT * FROM tv_user WHERE 1 = 1 ";
        if (!empty($username)) {
            $sql .= " AND username = '{$username}' ";
        }

        if (!empty($active)) {
            $sql .= " AND active = '{$active}' ";
        }

        $query = $this->db->query($sql);
        return ($query->num_rows() > 0);
    }

    function getUserByEmail($email, $active=NULL)
    {
        if (empty($email)) {
            return null;
        }

        $sql = "SELECT * FROM tv_user WHERE email = '{$email}' ";

        if (!empty($active)) {
            $sql .= " AND active = '{$active}' ";
        }

        $query = $this->db->query($sql);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            foreach ($row as $key => $val) {
                $this->$key = $val;
            }
            return $row;
        }
        return null;
    }

    function getSocialUser($uid=NULL, $provider,$email=NULL, $active=NULL)
    {
        if (empty($provider)) {
            return null;
        }
        $sql = "SELECT * FROM tv_user WHERE 1 = 1 ";
        if (!empty($uid)) {
            $sql .= " AND uid = '{$uid}' ";
        }

        if (!empty($email)) {
            $sql .= " AND email = '{$email}' ";
        }

        $sql .= " AND provider='{$provider}'";

        if (!empty($active)) {
            $sql .= " AND active = '{$active}' ";
        }

        $query = $this->db->query($sql);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            foreach ($row as $key => $val) {
                $this->$key = $val;
            }
            return $row;
        }
        return null;
    }

    function uuid()
    {
        return strtoupper(substr(dechex(time()).dechex(mt_rand(1,65535)), 0, 6));
    }

    function add($data)
    {
        return $this->db->insert("tv_user", $data);
    }

    function update($data, $where)
    {
        return $this->db->update("tv_user", $data, $where);
    }

    function delete($where)
    {
        return $this->db->delete("tv_user", $where);
    }

    function login($username, $password)
    {
        if (empty($username) || empty($password)) {
            return FALSE;
        }

        $password = md5($password);
        $sql      = "SELECT * FROM tv_user WHERE username='{$username}' AND password='{$password}' AND active=1";
        $query    = $this->db->query($sql);

        if ($query->num_rows() > 0) {

            $user = $query->row();
            $user_data = array();

            foreach($user as $key => $val){
                $user_data[$key] = $val;
            }

            $user_data["login"] = TRUE;
            $this->session->set_userdata('user', $user_data);

            if ($user->user_type == USR_ROOT) {
                $this->session->set_userdata('root_addmin_logged_in', TRUE);
                $this->session->set_userdata('addmin_logged_in', TRUE);
            }
            else if (in_array($user->user_type, array(USR_ADMIN,USR_MODERATOR,USR_TOUR,USR_HOTEL,USR_FLIGHT,USR_VISA))) {
                $this->session->set_userdata('root_addmin_logged_in', FALSE);
                $this->session->set_userdata('addmin_logged_in', TRUE);
            }
            else {
                $this->session->set_userdata('root_addmin_logged_in', FALSE);
                $this->session->set_userdata('addmin_logged_in', FALSE);
            }
            $this->session->set_userdata('logged_in', TRUE);
            $this->session->set_userdata('logged_user', $user);

            return TRUE;
        }

        return FALSE;
    }

    function logout()
    {
        $this->session->sess_destroy();
    }

    function verify_reset_password_code($email, $code)
    {
        if (empty($email) || empty($code)) {
            return FALSE;
        }

        $sql = "SELECT * FROM tv_user WHERE email = '{$email}' ";
        $query = $this->db->query($sql);
        if ($query->num_rows() > 0) {
            $row = $query->row();
            return ($code == md5(SITE_NAME.$row->fullname))? TRUE : FALSE;
        } else {
            return FALSE;
        }
    }
}
?>

2 个答案:

答案 0 :(得分:0)

根据评论:

您的第一块PHP出现在HTML视图中 - 包含屏幕截图的好主意!这表明它没有被解析为PHP,而是被解析为HTML,所以我会检查一下<?php是否出现在开头。

答案 1 :(得分:0)

short_open_tag=On
php.ini

中的

重新启动Apache服务器。