CodeIgniter: Controller::view() results in a "404 not found" error in PHP v4.4.2

If you have a controller “Blah” and a method “view”, accessing it via the browser like:


results in a “404 not found” error if your PHP installation is PHP v4.4.2. Not verified for any other 4.x versions.

The same code works in PHP 5.2.0-8+etch5, so I believe it is a bug, possibly in system/codeigniter/Base4.php.

I tried to support a bug report, but I need to be registered first, but the registration form for the forums is broken. So here is my bug report.


jQuery: $ namespace conflict with TinyMCE

I wanted to add a rich text editor one day, so I was looking at TinyMCE. This is a nicely done editor written in JavaScript. Now I’ve used it before, basically you include the main script, and it changes the textarea elements into a nice editor. I downloaded the 2.1.2 version, and it didn’t work.

Somehow TinyMCE conflicts with jQuery v1.1.3.1 — I used the pack-ed version. Or vice-versa. Anyway, to solve the problem:

jQuery.noConflict(); // use jQuery instead $ from here on

jQuery(document).ready(function() {

Read more about it here.

CodeIgniter: jQuery $.ajax goodness

I’ve been using the jQuery JavaScript library for sometime now. It actually makes writing client-side programming fun, wow! The AJAX functionality is a joy to use; you can submit requests as POST instead of GET since the former is not available in the CodeIgniter PHP framework.

Say you have a controller user.php and a view user_add.php. Now you want to submit an AJAX request to the server to check if the (presumably unique) username field is available for use.

$(document).ready(function() { // user_add.php
	$('#username').blur(function() {
			url: 'username_callback/' + $(this).val(),
			type: 'post',
			success: function(result) {
				$('#username_check').attr('innerHTML', result);

// html: user_add.php

So we’ve added an anonymous function to the username element. When it loses focus, we’ll submit a POST request to your your user controller, username_callback method. On success, we’ll replace the content (innerHTML) of the span username_check with the value returned by the PHP function.

I’m using the site_url() helper function to get my CI installation URL. NOTE: You’ll need to include this in the user.php constructor or in the autoloader.

// php: user.php

class User extends Controller
	function User()

	function username_callback()
		$s = trim(strip_tags($_POST['username'])); // clean

		if ($s == 'admin') { // error
			print 'The username 'admin' is reserved.'

username_check() will check if the POST-ed parameter is ‘admin’, and complain if so. So there you have it. That wasn’t too difficult, wasn’t it?

P.S. I would have loved to post up a working example but WP won’t accept .zip files.