FAQ Database Discussion Community


converting php functions that deal with sessions into codeigniter

codeigniter,session,codeigniter-2
I have two functions that deal with sessions and i need to convert them into codeigniter way.I managed to do the first one but i am stuck at accessing session array index at the second one first function: function addItem($pid,$qty=1){ $_SESSION['basket'][$pid]['kty']=$qty; } turned into: function addItem($pid,$qty=1){ $arr=array($pid=>array('kty'=>$qty)); $this->session->set_userdata('basket',$arr); } second...

codeignter form data is not inserting into MSSQL database

php,sql-server,codeigniter-2
I have a simple form setup. It shows up fine and when I hit submit looks like it is working, but when I go to check the datat in MSSQL Server it is not there. I am not sure why it is not working. Controller is insert.php <?php class insert...

If the value inside NOT IN is empty mysql is throwing an error

php,mysql,codeigniter,codeigniter-2,notin
If m.message_type_id IN () is empty it is giving me an error which says You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ) UNION ( ' at line 16 SELECT m.id,m.log,message,images,videos,uo.user_id as...

Heroku PHP app crash bash: vendor/bin/heroku-php-apache2: No such file or directory

php,heroku,codeigniter-2
I'm not very good with Heroku setup I'm trying to put online an app in PHP (with Code Igniter) but it doesn't work well. Here is the error : Heroku PHP app crash bash: vendor/bin/heroku-php-apache2: No such file or directory index.php is in root folder. Vendor directory also in root...

unable to get form_validation->set_rules and form_validation->set_message error

php,codeigniter,codeigniter-2,codeigniter-3
I have autoload helper form and library form-validation in autoload.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Login extends CI_Controller { var $data; public function __construct(){ parent::__construct(); $this->data=array('page'=>'login_view','title'=>'login'); $this->load->model("Login_model"); } public function index() { //get the posted values $data=$this->data; $this->load->view('template',$data); } public function checklogin(){ //form validation $data=$this->data;...

Variable inside get_filenames function using CodeIgniter and PHP

php,codeigniter,codeigniter-2
With the following code I am trying to get the file name inside MY_PIC folder and then to print it but is not possible. $this->load->helper('file'); $uid = 10; $files = get_filenames('./MAINDIRECTORY/<? echo $uid; ?>/MY_PIC'); print_r($files); The only way to get the filename is the following: $this->load->helper('file'); $files = get_filenames('./MAINDIRECTORY/10/MY_PIC'); print_r($files);...

session needs to be automatically destroyed after redirect if session data is in other language(other than english)

php,codeigniter-2
I am using codeigniter 2.2.1 and i have major issue in session. when i am trying to store session value in chinese or other language session destroy after redirection of page. any one have idea how to handle this error.my website is on 72 languages and i have to store...

Codeigniter object cache doesnt work

codeigniter,caching,codeigniter-2
I'm trying to save into the cache a json web response, my controller it's pretty simple, here's: <?php defined('BASEPATH') OR exit('No direct script access allowed'); include_once APPPATH . 'models/presenters/Radio.php'; use Streame\Model\Presenter\Radio as Radio; use Streame\Model\Presenter\Genre as Genre; class Test extends MY_Controller { public function index(){ $this->load->driver('cache'); if (! $cache_data =...

How to extract data from this array in ci

php,arrays,codeigniter,codeigniter-2,associative-array
Array ( [0] => Array ( [name] => Chennai [id] => 98 ) [1] => Array ( [name] => India [id] => 99 ) [2] => Array ( [name] => South India [id] => 100 ) [3] => Array ( [name] => North India [id] => 101 ) [4] =>...

In CodeIgniter 2.2.0, why does the form validator not invoke my custom validation routine on array input data?

php,codeigniter,validation,codeigniter-2,codeigniter-form-helper
Here's the situation: While building a project in CodeIgniter 2.2.0, I was attempting to validate a tabular form with a custom data validator. The tabular form was set up to transmit POST data to the server in standard array format, and I was using non-zero based numeric keys. My keys,...

update nestet set tree with php and nestable.js jquery plugin

php,jquery,nested,codeigniter-2
EDIT: After great answer the @vadim-ashikhman. The end of the question. Good Afternoon, First of all I want to say that I've been looking everywhere and have not found any response that is equal to is. Resources I'm using: PHP Framework Codeigniter Nested set Library : https://github.com/olimortimer/ci-nested-sets/ Jquery library:...

Holding Array of Values with Codeigniter ruri_to_assoc()

php,codeigniter,url,codeigniter-2
I'm consutructing a gallery which will use the URI to define a set of filter settings. Codeingiter's ruri_to_assoc() works brilliant for the majority of my settings as they are as simple as key=>value. However, one value (tags) can contian a number of values that I wish to match against. As...

When I click to the next page on pagination, 404 error run

codeigniter,pagination,codeigniter-2
I was trying to do pagination in CodeIgniter but I did something wrong I guess. The pagination links are seen on the bottom of the page. (OK) When I click the numbers on the pagination links, an error (404) is occurred. (This is the problem I couldn't solve) My codes...

CodeIgniter update query gets executed twice

php,codeigniter-2
I am using CodeIgniter 2.2. I have to update database with +1 every time a page is visited. Code works but it get incremented by +2 every time. Example: if total views=2, once the page is clicked total views should be 3, but the value in the database is 4....

CodeIgniter Input , and Validation

php,codeigniter,validation,codeigniter-2
I am using codeIgniter 2.2.2. In a Controller I captured the input so that I pass it back to the view in case the validation is failed, so that user is not forced to fill all the fields from the start, I set the following variable through $data array $data['fullname']...

What is wrong with this ajax.js code?

javascript,php,jquery,ajax,codeigniter-2
This function is intended to check whether or not a user login exists or might be available, but even with an empty user database table the form always displays that it is a duplicate and thus the submit button goes away. What is wrong with the script? function cre_username() {...

Codeigniter PHP Mailer, Sender Info

php,email,codeigniter-2,phpmailer,contact-form
I'm using Codeigniter PHP Mailer which is hosted here: https://github.com/ivantcholakov/codeigniter-phpmailer/ and with gmail smtp it works flawless. However,using it for a standard contact form, when visitors use that contact form and send us an email, they basically send mails from our mail address to our another mail addess. When they...

Codeigniter 2.0: Upload various files with form inputs with different names

php,codeigniter,file-upload,upload,codeigniter-2
I have a spent a few weeks with this issue, and have to ask you for help, I'm using Codeigniter 2.0, and load the file_upload library from autoload.php, but for some reason the files cannot be uploaded, and does not show any error when I do the do_upload function, here...

Need help Modifying how data is displayed via javascript and jquery

javascript,php,jquery,html,codeigniter-2
I have the code below and I need a little help in modifying the code output. The code below is for a Codeigniter chat application where the user enters their message in the text box (#text) and the message is output, the message is saved in a MySQL database via...

Read data from MySQL table and print only a specific item of each line in codeigniter view

php,codeigniter,codeigniter-2
In the model (model_users) I have the following : public function members_list() { $query = $this->db->get('USERS'); return $query->result(); } In the controler I have the following function: public function members_list() { $this->load->view('members_list_view'); } In the view file I have the following code: $this->load->model('model_users'); $membersArray = $this->model_users->members_list(); foreach ($membersArray as $v1)...

Codeigniter pagination last link

php,codeigniter,codeigniter-2
I have configured my application for using pagination. I know to give the first and last link as $config['first_link'] = 'First'; and $config['last_link'] = 'Last'; But how can i do for the next link Help pls...

SQL count Not sure How to get it to work with model, view and controller

php,mysql,codeigniter-2
I am not sure on how to do this with the model, view, and controller. I currently have it in the view only. I know this is bad practice that is why I am trying to see if I can get help. I have google how to create count but...

MySQL Using SUM with multiple joins

php,mysql,sql,codeigniter-2
I have a projects table and a tasks table I want to do a query that gets all projects and the sum of the time_spent columns grouped by project id. So essentially list all projects and get the total of all the time_spent columns in the tasks table belonging to...

Sorting array object in php

php,arrays,codeigniter-2,associative-array
Array ( [0] => Array ( [post_id] => 70 [percentage] => 66.666666666667 ) [1] => Array ( [post_id] => 72 [percentage] => 44.444444444444 ) [2] => Array ( [post_id] => 74 [percentage] => 11.111111111111 ) [3] => Array ( [post_id] => 82 [percentage] => 60 ) ) How to sort...

Form Validation on CodeIgniter Cart page

php,validation,codeigniter-2,shopping-cart
CodeIgniter v2.1.2 I have a very simple CodeIgniter shopping cart page setup as per the CodeIgniter documentation. This Cart page shows however many products are in the shopping cart and the input elements for editing the quantity of each have name attributes assigned as follows: 1[qty], 2[qty], 3[qty], 4[qty], 5[qty],...

Creating export and import in codeigniter i need an assistant

javascript,php,html,codeigniter,codeigniter-2
I need an assistant with creating export and import file in codeigniter, I am not advanced in coding, I am still learning. I didn't add export button as I also need an assistant on how to add it Here is my view <form method="post" action="<?php echo base_url() ?>csv/importcsv" enctype="multipart/form-data"> <input...

Summernote - Text displayed as raw HTML on validation

javascript,php,jquery,html,codeigniter-2
I am using Codeiginter with Summernote on front end - Now In a form, when some fields are empty, the same page loads with validation checking. I am using the following JS and CI code: $(window).load(function(){ <?php if(isset($article['text'])) { ?> $('#summernote').code('<?php echo $article['text']; ?>'); <?php } else { ?> $('#summernote').code('<?php...

Can we pass array and object from controller to view at same time in ci?

codeigniter,model-view-controller,codeigniter-2
i have object like this $interest Array ( [0] => Array ( [item_id] => 7 [item_name] => Jogging ) [1] => Array ( [item_id] => 8 [item_name] => Entertainment ) ) and array like this $profile Array ( [username] => admin [email] => [fullname] => [profile] => http://pickaface.net/includes/themes/clean/img/slide4.png ) i...

Error ILIKE on PostgreSQL

php,postgresql,codeigniter-2
I've a project that use PostgreSQL and new with it. Below is the error that i was facing. I also has searched on google but cannot find the solution. Fatal error: Call to undefined method CI_DB_postgre_driver::ilike() in D:\htdocs\poes\system\application\rapyd\classes\datafilter.php on line 162 I'm using codeigniter framework. This code is from datafilter.php...

How can solve CI_DB_mysql_result

mysql,codeigniter,codeigniter-2
Hello everybody i have problem with my page i have controller name user and i need get value from my function and used it in another function but i have problem : Message: Object of class CI_DB_mysql_result could not be converted to string Filename: database/DB_active_rec.php Line Number: ** my code...

How to get/set Header in Rest Server API?

php,codeigniter,codeigniter-2,codeigniter-restserver
i have a chriskacerguis Rest Server ,that listen for a client request as usually an API Server do. base on client request i want to send/response some data to client in header only. my question are: how do i access Client header first? then how do i set Header in...

How to pass variables while calling a function in codeIgniter

php,codeigniter,codeigniter-2
I am trying to create a rest api using codeIgniter. I have a method which gives a json object from android (client). Below is the function in my controller function addUser_post(){ $username = $this->post('username'); $password = $this->post('password'); echo $username; echo $password; $this->load->model('register_model'); $data = $this->register_model->addUser($username,$password); $this->response($data,200); } Below is my...

Bulk Exporting Data from Codeignitor to CSV using Database Utility Class

php,database,codeigniter,datatable,codeigniter-2
Here is my code: function export_csv() { $st = $this->input->get('st'); //Start Date $en = $this->input->get('en'); //End Date $sTable = 'TABLE_NAME'; $this->load->dbutil(); $aColumns = array('tempdisplayid AS ucid','uui','campaign_name','location','caller_id','skill','calltime','answertime','TIMEDIFF(answertime,calltime) as...

Code Ignitor White Page using new server

php,codeigniter,codeigniter-2,codeigniter-url
I have been running a CI app on my Apache2 server w/ PHP version "5.5.9-1ubuntu4.2". Everything runs fine. Now, I installed a second OpenLiteSpeed webserver, which is running PHP version "5.6.5" (I have tried different versions). This server is running in parallel with apache, but on a different port (8088)....

Codeigniter not returning all the rows from the database

php,codeigniter-2
Sorry if any of you find this question a dumb one. Here's my problem: I'm trying to retrieve all data from my database using the following query: $this->db->where('chart_module', 'leads'); $query = $this->db->get('vtiger_charts')->result_array(); but I have no luck. I tried selecting just one field and get the result using result() but...

Only last element stores in array in CI

php,arrays,codeigniter,codeigniter-2,associative-array
I'm using array in ci . whenever i store i can get only the last elements ! other elements are overwrite. this is my code $table="wp_term_taxonomy"; $data=array(); $this->db->where('taxonomy','Geographical'); $query = $this->db->get($table); if ($query->num_rows() > 0) { foreach ($query->result() as $value) { $terms_id=$value->term_id; $table2="wp_terms"; $this->db->where('term_id',$terms_id); $query2 = $this->db->get($table2); if ($query2->num_rows() >...

Codeigniter - Format date in WHERE clause

mysql,sql,codeigniter,activerecord,codeigniter-2
Is it possible to format the following date in an active record where clause? I need to format channel_titles.entry_date to be in the format Y-m-d, like the $yesterday variable. $yesterday = date('Y-m-d', strtotime('yesterday')); $this->db->where('channel_titles.entry_date', $yesterday); ...

Error Fatal error: Call to a member function insert() on a non-object

php,mysql,codeigniter,codeigniter-2,crud
I'm using a callback after inserting in the database, to pass values to this other table, i think the method i used its fine. But it gives me this error when its inserting to the other table in the database, probably in my model, or something in the controller im...

MVC CodeIgniter, trouble getting array to pass to view

php,model-view-controller,codeigniter-2
The idea is I am checking the database for values dependant on wether the fields are null depends on the state of the button, get_login_state() works correctly with the desired result, however get_break_state() does not. In my controller in the if($resultTwo){} The code in here never executes but resultTwo collects...

how to add a location header to http response from codeigniter rest server

php,rest,http-headers,codeigniter-2,codeigniter-restserver
I have a codeigniter rest api, created using this library: https://github.com/chriskacerguis/codeigniter-restserver For my POST method, once the resource has been successfully created, I would like to include a location header that includes a URI to GET the newly created / updated resource. It's not clear to me how to do...

Codeigniter 2.2.2 / How to print the array data in a “View” which is passed in from a controller?

php,codeigniter-2
I am not receiving any of the "country" data that I am passing from my controller to my view. Here is my controller: public function country_destination() { $this->load->model('model_admin'); //Calling the get_unique_states() function to get the arr of state. Model already loaded. $arrCountries = $this->model_admin->get_unique_countries(); //Getting the final array in the...

I am stuck with this mysql inner join query

mysql,inner-join,codeigniter-2
select t1.TITLE,PJT_ID, group_concat(t2.count) as COUNT, group_concat(t2.CREATED_BY) USERS,t2.task_id,group_concat(dc_users.PHOTO)as PHOTO from dc_tasks t1 inner join (SELECT dc_remarks.`CREATED_BY`,dc_sprints.PJT_ID , TSK_ID AS task_id, count( dc_remarks.`CREATED_BY` ) AS count FROM dc_remarks inner join dc_tasks on dc_remarks.`TSK_ID` = dc_tasks.ID inner join dc_sprints on dc_sprints.ID=dc_tasks.SPT_ID WHERE DATE( `CREATED_ON` ) = DATE('2015-05-22') AND dc_sprints.PJT_ID = GROUP BY `CREATED_BY`...

Pagination not adding the class

php,codeigniter,pagination,codeigniter-2
I am using pagination and here is the code $this->load->library('pagination'); $config['first_link'] = 'First'; $config['first_tag_close'] = '</div>'; $config['last_link'] = 'Last'; $config['last_tag_open'] = '<div>'; $config['last_tag_close'] = '</div>'; $config['full_tag_open'] = '<ul>'; $config['full_tag_close'] = '</ul>'; $config['num_tag_open'] = '<li>'; $config['num_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a>'; $config['cur_tag_close'] =...

What should I use in this situation? (Code Igniter) [closed]

codeigniter,codeigniter-2
I'm building online math exam, the user chooses the subject, and my program generates a view with all the questions from the selected subject. HELP IN THIS PART: After submiting the answers, I want that the system reload the page, preserving the selected options, and color the right options green....

Uploadify with Codeigniter 3 loosing cookie/session

php,jquery,codeigniter,codeigniter-2,uploadify
I am having some issues with Codeigniter 3 session. On the previous version, it was working fine until I upgraded to CI3. I implemented uplodify which is a file/image uploader. The code is too long to post here, I try to simplify it. Here is add photo view file: <input...

CodeIgniter 2 MSSQL query returns false instead of resource

sql-server,codeigniter-2
I'm new to CodeIgniter, one of the projects at my new job was built in CodeIgniter so I am sort of using pieces the previous programmer wrote as a basis. Im trying to create a method in our orders_model that contains a query that I cannot get any results from....

AJAX request takes too long to complete the request

php,mysql,ajax,json,codeigniter-2
I have a MySQL query which gets 17000 rows. If i execute that query directly in MySQL terminal using Putty, it takes 17 ~ 20 sec to get all rows. This is fine. But when i tried to execute the query using PHP with an AJAX request, It takes 50...

Codeigniter URL routing issues in .htaccess

php,apache,.htaccess,codeigniter-2
Before you mark it as duplicate FIY I have tried all solutions I could find on SO. The url is www.deltadigital.ca config file (if I use $config['base_url'] = 'http://www.deltadigital.ca' - it doesnt work at all) //$config['base_url'] = 'http://www.deltadigital.ca'; $root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST']; $root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $config['base_url'] = $root;...

How to retrieve value of radio button and insert into database in code igniter?

javascript,php,html,codeigniter-2
I have a form named feedback.php with two questions.I want to retreat the value of selected radio button and insert into database in code igniter. The table name is 'feedback' where i am storing this values. html code for form is here <form role="form" method="post" name ="your_form" action="<?php echo base_url();?>/index.php/feedback_model/index"...

is it possible to create CRUD generator in codeigniter just like Yii and CakePHP?

php,codeigniter,codeigniter-2,crud,grocery-crud
previously i worked on Yii framework but after my job change i have to work on codeigniter.but in Yii there is one helper/plugin like when you create database table and once you enter your table in one form and click OK button then it will generate CRUD operation automatically and...

Codeignitor 2.x, ActiveRecord, var_dump(), what is the expected result?

php,codeigniter,codeigniter-2
I am trying to debug some problems I am having with viewing data from a database. I am using codeignitor 2.x and active records. Here is my code: $data = $this->db->select('country_id', 'country')->from('mhcountry')->get()->result(); var_dump($data); die; Var_dump returns the following: array(20) { [0]=> object(stdClass)#21 (1) { ["country_id"]=> string(1) "1" } [1]=> object(stdClass)#22...

How do thumbnail image with a CI Image_nation library?

php,codeigniter,codeigniter-2
I use a new image library in Codeignite for make thumbnails. So, following example I tried to make thumbnail of uploaded image: $ci =& get_instance(); $ci->load->library('image_nation'); $conf = array( '145x145' => array( 'master_dim' => 'auto', 'keep_aspect_ratio' => FALSE, 'style' => array('vertical'=>'center','horizontal'=>'center'), 'overwrite' => TRUE, 'size_folders' => TRUE, 'quality' => '100%',...