Reputation: 23
I am newbie to codeigniter i am developed a website from past few days. The website working well on the localhost.but when i tested that that website on live web server i gives out following error:
500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. i tried a lot of things like .htaccess solutions available on different tutorials but not successful. Then i tried my self debugging and found that when i comment out the model loading line my index page get loaded without that data to have to get from the db.But as soon as i remove comment from that line it again gives me the same error. Then i checked my model i wont find any such problem.Now i am not using any .htaccess. PHP version on server:5.2.17 codeigniter version:CodeIgniter_2.1.4
------------------------My code for controller is---------------------------------
<?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);
}
}
?>
------------------------My code for Model is---------------------------------
<?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...
Upvotes: 0
Views: 1033
Reputation: 424
This problem might be a cause of a misconfigured .htaccess file on the root folder of CI.
Try using this for your .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /mypage/test1 <-----MODIFY THIS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
Also, go to config.php inside the config folder set it to blank.
Upvotes: 0