我是codeigniter的新手,我从过去几天开始开发了一个网站。该网站在 localhost 上运行良好。但是当我在实时 Web 服务器上测试该网站时,我给出了以下错误:
500内部服务器错误。您要查找的资源有问题,无法显示。我尝试了很多不同的教程中可用的 .htaccess 解决方案,但没有成功。然后我尝试了自我调试,发现当我注释掉模型加载行时,我的索引页面被加载而没有必须从数据库中获取的数据。但是一旦我从该行中删除注释,它就会再次给我同样的错误. 然后我检查了我的模型我不会发现任何这样的问题。现在我没有使用任何.htaccess。服务器上的 PHP 版本:5.2.17 codeigniter 版本:CodeIgniter_2.1.4
------------------------我的控制器代码是---------- ------------
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php
class video extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->model('video_model');
$this->load->helper('html');
$this->load->library('session');
}
function index()
{
$this->session->unset_userdata('searchterm');
$data['latest_video']=$this->latest_video();
$data['uk_video']=$this->uk_video();
$data['hm_video']=$this->hm_video();
$this->load->view('index',$data);
}
function watch()
{
$v_type=$this->uri->segment(3);
$v_id=$this->uri->segment(4);
if($v_type && $v_id)
{
$data['multiple_videos']=$this->video_model->get_all_videos($v_type);
$data['single_video']=$this->video_model->get_single_video($v_id,$v_type);
$counter= $data['single_video'][0]['counter'];
$id= $data['single_video'][0]['v_id'];
$this->load->view('watch',$data);
$this->view_counter($id,$counter);
}
else
{
redirect('video','refresh');
}
}
function latest_video()
{
$data[]=$this->video_model->get_latest_video();
return $data;
}
function uk_video()
{
$data[]=$this->video_model->get_uttrakhand_video();
return $data;
}
function hm_video()
{
$data[]=$this->video_model->get_himachal_video();
return $data;
}
function result()
{
$this->load->view('search');
}
function view_counter($id,$counter)
{
$user_ip=$this->input->ip_address();
if(!$this->input->cookie($id))
{
$cookie=array('name'=>$id,'value'=>$user_ip,'expire'=>43200);
$this->input->set_cookie($cookie);
$counter++;
}
if($this->input->cookie($id))
{
if($this->input->cookie($id,TRUE)!=$user_ip)
{
$counter=+$counter;
}
}
$update=array('counter'=>$counter);
$this->db->where('v_id',$id);
$this->db->update('tblvideo',$update);
}
}
?>
---------------------我的模型代码是---------- ------------
<?php class video_model extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
function get_latest_video()
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->order_by('v_time','DESC')->limit(3);
$query=$this->db->get();
return $latest_data=$query->result_array();
}
function get_uttrakhand_video()
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->where('v_type','uk')->order_by('v_time','DESC')->limit(4,3);
$query=$this->db->get();
return $latest_data=$query->result_array();
}
function get_himachal_video()
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->where('v_type','hm')->order_by('v_time','DESC')->limit(4,3);
$query=$this->db->get();
return $latest_data=$query->result_array();
}
function insert_data()
{
$data=array(
'v_title'=>$this->input->post('v_title'),
'v_name'=>$this->input->post('v_name'),
'v_description'=>$this->input->post('v_description'),
'v_tags'=>$this->input->post('v_tags'),
'v_duration'=>$this->input->post('v_duration'),
'v_type'=>$this->input->post('v_type')
);
return $this->db->insert('tblvideo',$data);
echo "data inserted";
}
function get_single_video($v_id,$v_type)
{
$cond=array('v_id'=>$v_id,'v_type'=>$v_type);
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->where($cond);
$res=$this->db->get();
return $res->result_array();
}
function get_all_videos($v_type)
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->where('v_type',$v_type)->order_by('v_time','DESC')->limit(30);
$query=$this->db->get();
return $query->result_array();
}
function get_video_list($limit,$offset)
{
$offset=intval($offset);
$this->db->select('v_id,v_name,v_title,v_description,v_tags,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->order_by('v_time','DESC')->limit($limit,$offset);
$query=$this->db->get();
return $query->result_array();
}
function get_total_number_videos()
{
$this->db->select('v_id,v_name,v_title,v_description,v_tags,v_image,v_type,v_duration,v_time,counter')->from('tblvideo')->order_by('v_time','DESC');
$query=$this->db->get();
return $query->num_rows();
}
function video_edit($v_id)
{
$this->db->select('v_id,v_name,v_title,v_description,v_image,v_tags,v_type,v_duration,v_time')->from('tblvideo')->where('v_id',$v_id);
$query=$this->db->get();
return $query->result_array();
}
function video_update($id,$table,$form_data)
{
$this->db->where('v_id',$id);
return $response=$this->db->update($table,$form_data);
}
function delete($id,$table)
{
$this->db->delete($table, array('v_id' => $id));
}
function user_authentication($u_name,$pwd)
{
$array=array('username'=>$u_name,'password'=>$pwd,'type'=>'admin');
$this->db->select('username,password,id,type')->from('tblusers')->where($array);
$query=$this->db->get();
return $query->num_rows();
}
function user_data($u_name,$pwd)
{
$array=array('username'=>$u_name,'password'=>$pwd,'type'=>'admin');
$this->db->select('username,password,id,type')->from('tblusers')->where($array);
$query=$this->db->get();
return $query->result_array();
}
}?>
please take look at the problem thank you...