codeigniter

CodeIgniter: json_decode array issues

On my client side I'm sending an ajax request with jQuery in the following matter: $.post(script.php, { "var1":"something", "var2":"[1,2,3]" }, function(data) { }, "json"); On the server side, in the CodeIgniter's controller I'm receiving the values like so: $var1 = trim($this->input->post('var1')); $var2 = trim($this->input->post('v...

Codeigniter: Using URIs with forms

I'm using URIs to direct a function in a library... View File (It's huge, so I'm just posting the opening line): <?php print form_open('survey',array('class'=>'horizontal','id'=>'form_survey'))?> Library: function survey_form($container) { $id = $this->CI->session->userdata('id'); // Setup fields for($i=1;$i<18;$i++){ ...

How to change the value of a variable inside a controller from a view file (html)?

I followed this tutorial: http://codeigniter.com/wiki/Internationalization_and_the_Template_Parser_Class/ The controller that loads the language is this one: <?php class Example extends Controller { function Example() { parent::Controller(); # Load libraries $this->load->library('parser'); # Loa...

setting codeigniter mysql datetime column to time() always sets it to 0

Hi guys. I'm using Codeigniter for a small project, and my model works correctly except for the dates. I have a column defined: created_at datetime not null and my model code includes in its array passed into db->insert: 'created_at' => time() This produces a datetime value of 0000-00-00 00:00:00. When I change it to: 'created_at...

Content-disposition:inline header won't show images inline?

I'm trying to show an image inline on a page. It is being served by a codeigniter controller. class Asset extends MY_Controller { function index( $folder, $file ) { $asset = "assets/$folder/$file"; if ( !file_exists( $asset ) ) { show_404(); return; } switch ( $folder ) ...

How to redirect every uri calls to one controller, except some static ones?

Hey, I'm using codeigniter and want to make my portal a bit more SEO friendly. I have a controller (articles) which handles every article on my portal. The URL looks like this: example.com/articles/category-sub-category/article-name I'm using mod rewrite module to hide my index.php, and codeigniter routing to hide the controller actio...

[ask][php] find dynamic filename exist

hi. i am writing a cache module in php. it tries to write a cache with a $string+timestamp as a filename. i dont have problem with writing the cache. the problem is i do a foreach loop to get the cache that i want. this is the logic that i use for getting the cache foreach ($filenames as $filename){ if(strstr($filename,$cachenam...

Enable Query Strings in Code Igniter

Hey, I am trying to implement Twitter's OAuth into my Code Igniter web application at which the callback URL is /auth/ so once you have authenticated with Twitter you are taken to /auth/?oauth_token=SOME-TOKEN. I want to keep the nice clean URL's the framework provides using the /controller/method/ style of URL but I want to enable quer...

Codeigniter error logs show a 404 non-existing images directory...need to worry?

I've recently started logging my errors through codeIgniter. Since doing so, I have noticed a lot of 404 errors for directories that don't exist. For example: ERROR - 2010-05-15 21:06:26 --> 404 Page Not Found --> someController/images Where someController is, obviously, a controller. The problem is, there are no functions within that ...

upload 2 images at once in codeigniter

can anyone plz provide me a simple working code snippet of codeigniter for uploading 2 images at once (through 2 different input field ofcourse). I need 2 images to be uploaded at once, or one after another. and both of the images need to be in different location. I tried to make it myself by calling upload function twice but it return...

Linking and Redirecting between multiple applications running under a single system folder

I am running multiple applications with a single Codeigniter system/ folder using the recommended way on the Codeigniter wiki. Each application runs fine and I can link between apps using absolute URLs. Is there some way I can use or extend the URL helper class (functions like anchor(), redirect()... etc.) to generate links to controlle...

Using PHP interfaces in Codeigniter

I am trying to find out how can I used PHP interfaces in my MVC design. I want to make sure that the design enforces an interface so that any new module would follow that. For example: <?php interface BaseAPI { public function postMessage($msg); } class ServiceAPI implements BaseAPI { public function postMessage($msg) { ret...

CodeIgniter and SimpleTest -- How to make my first test?

I'm used to web development using LAMP, PHP5, MySQL plus NetBeans with Xdebug. Now I want to improve my development, by learning how to use (A) proper testing and (B) a framework. So I have set up CodeIgniter, SimpleTest and the easy Xdebug add-in for Firefox. This is great fun because maroonbytes provided me with clear instructions a...

Test a database conection without codeigniter throwing a fit, can it be done?

I'm just about finished my first release of automailer, a program I've been working on for a while now. I've just got to finish writing the installer. Its job is to rewrite the codigniter configs from templates. I've got the read/write stuff working, but I'd like to be able to test the server credentials given by the user without codingi...

CodeIgniter -- unable to use an object

THE SUMMARY: When I call .../index.php/product, I receive: Fatal error: Call to a member function get_prod_single() on a non-object in /var/www/sparts/main/controllers/product.php on line 16 The offending Line 16 is: $data['pn_oem'] = $this->product_model->get_prod_single($product_id); Looks like I don't know how to make ...

Using Wildcards in CodeIgniter

Wildcards are cool. I am trying to do this: $route["(:any)/controller"] = "controller"; basically, I want to put the wildcard in the front. It doesn't quite work, and I don't know any work around. ...

Call External Javascript function using Codeigniter

Hi, I need to call a javascript function from my controller in codeigniter.It is possible in codeigniter ? Problem Details My javascript file contains function debugOutput(msg) { alert (msg); } and also I need to call it from my controller. I done it as follows. <?php function check() { header('Content-type: application/x-javascri...

Codeigniter: how to foreach in javascript with a returned array

I need to loop through a returned array in javascript but it doesn't work, it will loop through each letter of the word array instead of looping throught the value. this is the javascript code $.ajax({ url: "<?php echo site_url('home/getsubcats'); ?>", type: 'POST', data: form_data, success: function(msg...

Weird insert behavior with mysql and codeginiter

I have a fairly simple insert statement <...> if (!empty($attributes)) { $sql = 'INSERT INTO `part_attrs` (`part_id`, `attr`, `type`, `list_order`) VALUES (?, ?, ?, ?)'; foreach($attributes as $key => $attribute) { $this->db->query($sql, array($partid, $attribute[0], $attribute[1], $key)); ...

How do I format an email for Gmail?

I'm sending out an email using CodeIgniter's built in library. All I'm trying to do is send a bolded string, but instead of rendering the tags, it is printing them. What I have: <html> <head> </head> <body> <b>Donkey</b> </body> </html> That is, character for character, the email I'm getting. Why aren't the tags rendering? ...