codeigniter-2

codeigniter base_url inside constants file

一世执手 提交于 2019-12-01 08:30:54
Currently I display images in the following way: <img src="<?php echo base_url().USER_UPLOAD_URL.$post['userPhoto'] ?>" /> USER_UPLOAD_URL is defined inside application/config/constants.php. define('USER_UPLOAD_URL', "uploads/user_uploads/"); Is there any way to include base_url() inside constants.php? In this way I wouldn't need to write each time base_url() inside view. Is there any alternative approach? tnx constants.php loading before config.php, so you can't use $config['base_url'] from constants.php. But you can do something like that: constants.php : define('BASE_URL', "http://mysite

Ajax requests not open to everyone

此生再无相见时 提交于 2019-12-01 08:10:56
I've created a webapp using CodeIgniter. There are several places where I use ajax in the application. I want to know if there is a way where I can stop direct access and query to the ajax controller and only allow legitimate ajax requests originating from the page to be processed. Thanks. Yes you can do this without a problem. The CodeIgniter input class has a method called is_ajax_request(). Simply check for this at the start of your controller action. For example: function ajax_save() { if ($this->input->is_ajax_request()) { //continue on as per usual } else { show_error("No direct access

Call to a member function num_rows() on a non-object

笑着哭i 提交于 2019-12-01 07:28:14
问题 I'm using CodeIgniter, and I want to get some data from a table in a database. in my Model, I have this function : public function fetch_cours($limit, $start, $element) { $id_element = $this->db->from('element') ->where('name',$element) ->limit(1) ->get() ->result(); $query = $this->db->from('cour') ->where('id_element',(int) $id_element[0]->id) ->limit($limit, $start) ->get() ->result(); var_dump($query); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; }

Routes in Codeigniter - 404 Page Not Found

孤街醉人 提交于 2019-12-01 06:26:18
Can someone tell me, where the issue is ?? This is my controller class Support extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('support_model'); $urlarray = array("index","delete"); if(!in_array($this->uri->segment(2),$urlarray)){ $this->viewticket($this->uri->segment(2)); } } public function viewticket($id){ if(!empty($id)){ $this->load->view('templates/logged_header'); $this->load->view('support/view'); $this->load->view('templates/footer'); } } } Here is my routes.php $route['default_controller'] = "welcome"; $route['benefits'] = 'welcome

codeigniter 2 and how to disabled xss for TinyMCE

坚强是说给别人听的谎言 提交于 2019-12-01 06:11:27
问题 ive searched every site including stackoverflow on this issue. I have XSS globally turned on and few pages I have use TinyMCE. On those pages I'd like the TinyMCE part to not have XSS enabled. After reading about 40 pages, they all say to do the following: $tiny_mce = $this->input->post('note'); // xss filtering off or $tiny_mce = $this->input->post('note', FALSE); // xss filtering off I have tried both, here is my model: public function edit($id) { $tiny_mce = $this->input->post('note'); //

codeigniter active record where, or_where?

我的未来我决定 提交于 2019-12-01 04:49:34
I am using Active Record on CodeIgniter. I am confused on which approach I should take. Currently, our login system let's the user to use username/email for the login along with the password. But my current active record, seems to let the user logged in if he choose to use the email + no password. Right now this is my query: $this->db->select('id,level,email,username'); $this->db->where('email',$user); $this->db->or_where('username',$user); $this->db->where('password',$pass); $query = $this->db->get('users'); if($query->num_rows>0) return TRUE; else return FALSE; Sample inputs: Username: test

Ajax requests not open to everyone

天大地大妈咪最大 提交于 2019-12-01 04:20:13
问题 I've created a webapp using CodeIgniter. There are several places where I use ajax in the application. I want to know if there is a way where I can stop direct access and query to the ajax controller and only allow legitimate ajax requests originating from the page to be processed. Thanks. 回答1: Yes you can do this without a problem. The CodeIgniter input class has a method called is_ajax_request(). Simply check for this at the start of your controller action. For example: function ajax_save()

Routes in Codeigniter - 404 Page Not Found

為{幸葍}努か 提交于 2019-12-01 04:14:52
问题 Can someone tell me, where the issue is ?? This is my controller class Support extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('support_model'); $urlarray = array("index","delete"); if(!in_array($this->uri->segment(2),$urlarray)){ $this->viewticket($this->uri->segment(2)); } } public function viewticket($id){ if(!empty($id)){ $this->load->view('templates/logged_header'); $this->load->view('support/view'); $this->load->view('templates/footer');

Codeigniter - Batch Update with Multiple Where Conditions

和自甴很熟 提交于 2019-12-01 03:05:21
For starters, the Codeigniter documentation on update_batch does not exist. kenjis was kind enough to provide some documentation and submit it to the repository. Hopefully they pull it soon. Does anyone know how to add multiple where conditions to Codeigniters update_batch command? My Desired Use: $where = array( 'title', 'name' ); $this->db->update_batch('mytable', $data, $where); When I tried this code I got the follow error: A Database Error Occurred One or more rows submitted for batch updating is missing the specified index. Filename: C:\wamp\www\wheel\system\database\DB_active_rec.php

Setting up codeigniter in Dreamweaver CS 5.5

≯℡__Kan透↙ 提交于 2019-12-01 02:00:57
I am looking for information on how to set up a code igniter project in Dreamweaver CS 5.5 with code hinting like you can for Zend framework. I have managed to set code igniter up in Dreamweaver CS5.5 by downloading the latest version of code igniter and placing in a folder called php_librarys on the root of my C: drive. I then followed the instructions for site specific code hinting here: How to set up site specific code hinting . The folder you need to point Dreamweaver to is the libraries folder in the system directory of Code igniter. Just make sure you select recursive and .php as the