codeigniter

preg_replace not working!

Here's my Codeigniter function: function edit_phone($phone) { if (preg_match('/^\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}$/', $phone)) { return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "$1-$2-$3", $phone); } else { $this->CI->validation->set_m...

CodeIgniter Route Problem with Regex

Hey guys, I have got a little problem using the CodeIgniter route function. I use the URI_Language_Identifier extension and I want to reroute all the requests for "lang/login" (e.g. en/login or de/login) to user/login I tried to use the routes function as follows, but it does not work: $route['(\w{2})/login'] = "/user/index"; this ho...

Designing Libraries in CodeIgniter

I am about to start writing my first big CodeIgniter application, but before I get started I was wondering what the role of libraries should be. I'm a newbie to MVC, but from what I gather the model should be where the data structures are stored (business logic). So is the library a place to write application logic, in addition to contro...

Codeigniter - re-populating form on failed validation after submitting

I have a form that requires the user to enter some information. If they fail to complete the required fields they are re-presented with the form; the top of the page notifying them what fields are required and I've enabled sticky forms (set_value()) so their input is not lost. I'm using flashdata to display messages to the user (i.e., ...

Pass a php variable to dynamically generated div's onclick event

hi, how to pass a php variable to dynamicaly generated div's onclick event? here is my code while($rowset = mysql_fetch_array($result)) { $idTT1++; $editTT='b'.$idTT1; $hidTextTT='t'.$idTT1; $hidSubIdTT='s'.$idTT1; echo "<tr><td>".$rowset[1]." ".$rowset[2]."</td><td> &nbsp; </td> <td class='table_label'> <...

How to take out .gif, .jpg or .png

I use Windows and I display a file extention. When I upload an image file with PHP, a image name of image1_big.jpg becomes image1_big.jpg.jpg. And image2.gif becomes image2.gif.gif. I don't want to turn off file extension. How can I avoid this problem? function addProduct(){ $data = array( 'name' => db_clean($_POST['na...

Upload problem with PHP: Thumbnail picking up the image name.

I have the following model(codeigniter) code to upload image and thumbnail. However the result of image path becomes, images/comfort_big.jpg and images/comfort_big.jpg.jpg. The thumbnail image picks up the name of image and add .jpg. I am uploading images/confort_thumb.jpg for thumb. Can anyone tell me what's wrong please? if ($_FIL...

301 redirect in codeigniter

ok, so i can't tell if this is a server issue or what. i've got an htaccess file like so: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/main/index/$1 [L] RewriteRule ^ajax/(.*...

Codeigniter validation

I have many goals to be printed on the screen. but it shows error when i use it like this echo $this->validation->rshort_goal.$i; What is the right way to use this? if($sgoal !='') { $scount = count($sgoal); $i =1; foreach($sgoal as $row) { <textarea name="rshort_goal<?php print $i;?>" id="short_goal" class="sho...

How to speed up image resizing in a CodeIgniter PHP application?

I have an application that allows users to upload images. The test case I use is a jpeg of 1.6MB with dimensions 3872 x 2592px. The upload script in the back-end will resize the uploaded image into 6 additional formats: square (small 75 x 75) Small Thumb (50 x 38) Thumb (100 x 76) Small (240 x 161) Medium (500 x 378) Large (1024 x 774)...

Storing real time data

Hello, I am building a website in which the user can select what list items they see in their navigation menu, my idea is to store the menu items that the user selects in a cookie as this will stop the need for the user to be registered member on the website, is it possible to store realtime data in a cookie and how would I do this? ...

Codeigniter - HTML not getting rendered

I have deployed my PHP application built on Codeigniter. When I call the root URL, browser is successfully redirected to login view but not HTML is rendered. What can be the issue? ...

CodeIgniter Loading Database Unnecessarily?

Hello all, Just started using CodeIgniter, loving it. Having enabled the database to be one of the libraries to be loaded. I noticed that on pages that I don't even use the database (static pages). CI complains: A Database Error Occurred Unable to connect to your database server using the provided settings. The error is not a...

After deployment to server codeigniter app gives 404

Hi, I'm developing on Mac OSX with MAMP. My app is built on top of CodeIgniter 1.7.2 and works fine on my develoment machine. Now I copied the to my test environment, which is Ubuntu Server 9.10. A standard, fresh CI install works perfectly but when I put my app in the same dir, I get errors. If I just go to my root, I get a 404. On ...

CodeIgniter activerecord, retrieve last insert id?

Are there any options to get the last insert id of a new record in CodeIgniter? $last_id = $this->db->insert('tablename', array('firstcolumn' => 'value', 'secondcolumn' => 'value') ); Considering the table consits of fields id (autoincrem...

Where should i start before using codeigniter with php?

Hai guys, As i am a newbie to codeigniter with php i dont know where to start please guide me with some useful links... ...

Codeigniter and SWFObject

Hello, I'm building a website using Flex, Codeigniter, and I use swfobject to embed the swf. This will not work if I access the website using Codeigniter's index.php file. This is the ouput source: <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <base href="http://localhost/Pixelatte-debu...

Should I use if statement? If yes, what will be good in this PHP case?

When I use function create_category(), it will create a directory with this name such as images/newfolder. Then I have a function edit_category() which checks post('name'). In a controller function edit_category($id=0){ if ($this->input->post('name')){ ... ... I don't want to allow to change the category name. It will create anoth...

How to compress images in CodeIgniter, yet do not change their dimensions?

I have a site where users can upload images. I process these images directly and resize them into 5 additional formats using the CodeIgniter Image Manipulation class. I do this quite efficiently as follow: I always resize from the previous format, instead of from the original I resize using an image quality of 90% which about halves th...

Does anyone know of a simple tutorial for Googles Federated Login

Im looking for a step by step tutorial that covers Google's Federated Login process using php and cURL. All needs to get dumped into codeIgnitor so it really needs to be easy to follow. ...