Code Igniter - Get Last URI Segment

I'm tying to get the last URI segment in CI, however I don't know what the number for it will be, as parameters (an integer) will be appended as the user clicks links within the page. These are then used in a controller to pull relevant database records into the page via ajax.

How can I tell CI to get the last segment?

Something like:

$record_num = $this->uri->segment($last);


Strip Tags That's Are NOT In [code] [/code] Segment?

I'm trying to find a way to strip tags from a user-inputted string except from tags that are wrapped in the [code] [/code] BB style tag.

For example, a user may enter this:


What I would like is the "hacked" alert to be removed, but not the "Hello" alert.

I would like to remove ALL tags (php, html, css, js) outside of the [code] but allow anything within them.

So far, I've got the following code to do the reverse of what I would like:


View 4 Replies View Related

Javascript - Beginner - Pass Variable From One Code Segment To Another ?

I have index.php which uploads a file to server and sets several PHP variables (like $target_folder_and_file_name).

index.php also has the following line (it was originally index.html):

<script language="JavaScript" src="main.js.php"></script>

After index.php returned to the browser, the browsers asks for main.js.php from the server (right?).

Can I access somehow $target_folder_and_file_name from the PHP code in main.js.php ?

View 3 Replies View Related

Execute Code Segment Only If Loop Reaches Its Last Cycle

Where is the most efficient position for a code block, which shall only execute, if a loop has reached its end, without having previously been aborted (via break or return)? Provided: "Some Code X" is always the same, only at different Code Segment Positions 1 and 2. I assume: 2 will be executed with the same reliability as 1. Am I wrong I know: 2 is obviously more efficient, as it is only called once after the loop ran $limit times, compared to 1, whose enclosing if-condition is called $limit times, and if once true, the code itself is called. Thus the efficiency difference is if-condition queried $limit times. Hence I conclude: To prefer using Code Segment 2 rather than Code Segment 1, unless my assumption is wrong!


View 3 Replies View Related

Code Igniter Form_input?

A couple questions here..What is the following syntax? What do all the pieces mean?

(( ! is_array($data)) ? $data : '')

How is it used in the function at the end?

function form_input($data = '', $value = '', $extra = '')
$defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
return "<input "._parse_form_attributes($data, $defaults).$extra." />";

View 4 Replies View Related

Implement RSS 2 In Code Igniter?

How can I implement RSS 2 in Code Igniter?

View 1 Replies View Related

Using Lightbox With Code Igniter?

I'm trying to use Lightbox with my CodeIgniter application. Lightbox says to put the following in the head tag:

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />


This displays the thumbnail version, and then when clicked I want it to go to the lightbox, but now it goes to a new tab with the large image.

I've used lightbox before and have always gotten it to work, I'm not really sure what the problem is now, and I tried moving the files all around to different spots but nothing worked.

View 1 Replies View Related

Code Igniter :: Use Get Values In CI?

In my projects i often use get params as a temporary way to test things with different values.However it seems like you cannot access get params in code igniter?I am aware I could build a param into my functions and pass the value as a url segment.But i dont want to be doing that every time I wish to test something.So,is there any way to use get values in CI?

View 2 Replies View Related

Obfuscator For Use With Code Igniter Code?

I am looking for an obfucator for my PHP code, the code which I am trying to obfucate uses the codeigniter framework. The obfuscators that I have tried, don't seem to be able to do it.

View 4 Replies View Related

Serving Different Views In Code Igniter

Is there best practice for serving different view for different context.For example, I'd like to serve specific pages for mobile user agents with the same controllers.

View 1 Replies View Related

Deploying Code Igniter 1.7.2 Application On IIS 7?

I developed a Codeigniter 1.7.2 on wamp and it's almost completed. Now i am trying to host it on IIS 7 (yes IIS! because the control panel that is offered to me only has IIS in it) i am getting errors. This is what i get


View 1 Replies View Related

Use A Code Igniter Class In Wordpress?

The class I wish to use is: url. How can I use this in a Wordpress project? Do I just take out the code igniter specific snippets out?

View 2 Replies View Related

Code Igniter Function Call 404?

I was going through the official Code Igniter tutorial when I hit a snag...The tutorial had me save and run this code:

class Blog extends Controller {
function index()


View 5 Replies View Related

Tell Code Igniter To Ignore / Lib / Css Path?

How can I tell CodeIgniter to ignore the /lib/css folder and load my stylesheets instead of trying to load things via my controller?

View 2 Replies View Related

CakePHP To Code Igniter Conversion?

I want to convert an application from CakePHP to Code Igniter. Has anyone tried to do this? With my CakePHP application almost all the coding has been done in the controller layer, with the models pretty much exactly as they come out of baking.

View 1 Replies View Related

Code Igniter Captcha Not Working?

code igniter captcha is not working in my page.My php gd library enabled but no change result.

View 3 Replies View Related

Setting Up Emails In Code Igniter 2.02

I'm getting a lot of errors. And I've tried several suggestion across different sites, deleted the parent function, removed the array, updated my php ini file, no luck. This is the first of 13 errors I'm getting. A PHP Error was encountered Severity: Warning Message: fsockopen() [function.fsockopen]: unable to connect to [URL] (Unable to find the socket transport sslā did you forget to enable it when you configured PHP?) Filename: libraries/Email.php Line Number: 1673

class Email extends CI_Controller
function index()
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://';
$config['smtp_port'] = 465;
$config['smtp_user'] = '';

View 1 Replies View Related

Jumping Controllers In Code Igniter

I am wanting to have a form of dynamic routing.

Basically I want to catch the 404 (done through routes.php 404_override).

This is easy enough.

But then what I want to do is run through a series of checks.

e.g pay no attention to the fact the is_xxx functions are not coming from anywhere

$what = $this->uri->segment(1);
//now I want to route this to the profile controller and call the display function like so
//display('vanity', $what);


How would I go about re-routing to the other controllers once the decision has been made?

View 1 Replies View Related

Insert AT&T It Will Add Semicolon In Code Igniter?

Whenever I was inserting AT&T to database it was added as AT&T; semicolon is added extra in code igniter.My code is like this:


View 2 Replies View Related

Logout Feature In Code Igniter?

I started using codeigniter for my project. I have user authentication system for my website. I have seen the videos from nettuts for the login information. I am confused why the logout is not working properly. I have the following logout function in my login controller.

function logout() {

If I click on the logout button I am redirecting the user to the main page. But after redirecting the user to the main page, if click on the back button on the browser I will see the logoff and my name on the top of the page. I need some help on where I am going wrong or is there any important piece of code I am missing in my controller I think I found the solution. I should append the following code into the appropriate controller

$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");

View 1 Replies View Related

Make A Breadcrumb With Code Igniter ?

best way to make a breadcrumb with Code Igniter.1 : Retrieve the strings with URLexample : this->uri->segment(2) 2 : Do you know another way ?I'd really like to have your opinion

View 1 Replies View Related

Set_value() Default In Code Igniter?

I've used formigniter to generate a form forThat bit works great. However I want to set a default value for the name field.The input code looks like this:

<label for="forename">Forename</label>
<?php echo form_error('forename'); ?>
<br /><input id="forename" type="text" name="forename" maxlength="255" value="<?php echo set_value('forename'); ?>" />

View 1 Replies View Related

Code Igniter Controller/Model Name Conflicts?

I have a controller and model both named "account" without getting "cannot redeclare class". I'd like to add a prefix to Models or Controllers, or preferably both.

View 2 Replies View Related

Code Igniter - Use Only Shopping Cart Class?

A client of mine has a big php website, and wants to add shopping cart functionality. Is it possible to use Code Igniter's shopping cart class, without writing the whole site in the Code Igniter framework? How?

View 3 Replies View Related

Routes - Moving First Steps With Code Igniter

I just moving my first steps with Code Igniter

I have a application/controller/login.php file containing the following


My routes definition looks like the following:

$route['default_controller'] = "welcome";
$route['login'] = 'login';
$route['scaffolding_trigger'] = "";

The problem is that i keep getting a 404 when i try to access [URL]. What did i do wrong? I've checked CI routes docs and cannot spot anything.

View 2 Replies View Related

Code Igniter With Flex Is It Good Combination?

im looking forward flex php developers about their works with CI and flex combination.did you guys feels good and keep things innovativeand im just looking for working samples you have or you came across

View 2 Replies View Related

Redirect With Code Igniter Doesn't Work

i'm trying to redirect to the index method of my main controller like so:

if($provider == '') {
redirect('/index/provider1/', 'location');

but that takes me [URL] when it should go to [URL]. does that make sense can anyone give any advice? this is what my htaccess looks like and i have index_page in config set to blank, although i don't think that the issue is htaccess here it is in case:


View 2 Replies View Related

Code Igniter [did Not Found Page Created]

My first page is leave_app.php. In this page I put a link to apply leave, using the normal code:
<a href="add.php">New Leave Application</a>

However the link didn't display as I had wished for.

"The requested URL /ci/add.php was not found on this server." and the link in the browser leads to this "url".

I don't know why the server didn't find the page. I already made add.php page, also add at the leave_app controller the function add().

In the config.php file I put $config['index_page'] = '';

I have asked around but no one can help. I have already surfed around, but still don't know how to solve.

View 1 Replies View Related

Having Code Igniter URI Segments For Multiple Variables?

I'm writing an app that allows you to filter database results based on Location and Category. If someone was to search for Liverpool under the Golf category the URI would be /index.php/search/Liverpool/Golf. Should someone want to search by Location but not category, they would be sent to /index.php/search/Liverpool However, should someone want to filter only by category they would be unable to use /index.php/search/Golf because that would be caught by the location search.

Is there a best practice way to have /index.php/search/Golf be recognised? Some best practice as to what else to add to the URI to make these two queries distinct? /index.php/search/category/Golf perhaps? Though that is beginning to show characteristics of /index.php?search&category=Golf which is exactly what I'm trying to avoid.

View 4 Replies View Related

Code Igniter Overriden DB Active Record?

I want to override the Active Record class (some functions of it at least). And I made a file called spj_DB_active_rec.php in a folder named "database" in my "application" folder but it does not work.class name is spj_DB_active_record

class spj_DB_active_record extends CI_DB_active_record {

View 1 Replies View Related

Load Code Igniter In An External File?

I have a problem with a flash call and I need to debug, before messing with the code I was wondering if it's possible to load the whole CI environment inside a xxx.php file.

Basically I would need to do this:


and only that, nothing should be loaded automagically, the thing is that once loaded the controller should be able to "see" all the models, libraries and config files.

Basically what I want is to be able to call CI forcing to load a specific controller->method.


I have been able to achieve this. If anybody stumbles upon this question and needs to do this, here is the file: [URL]

View 2 Replies View Related

Copyrights 2005-15, All rights reserved