Code Igniter redux - I'm an idiot

May 14 2006

Since my last post complaining of problems with Code Igniter, I finally tracked down the cause – PEBCAK as per normal.

Pay better attention to errors

In my frustration at what I thought was an online vs. offline configuration problem, I didn’t pay too much attention to the error message I was getting; on closer inspection, it turned out to be a line of a method of the database class that I wasn’t using in my function – weird, right?

Eventually I worked out that even though I was only calling the main function of my controller class, if there are any errors at all in the whole class it will throw an error and bomb out. I fixed the error I had in another function, and voila – everything works.

Use better function names

So what was the cause of the error? Well, there are certain keywords that are prohibited when naming your functions; I, lacking any kind of imagination, had chosen two of those restricted words, ‘view’ and ‘config’. Changing them to ‘viewing’ and ‘configuration’ fixed all the issues I was having. Update: I knew I’d seen a list of reserved function names somewhere – on the Quick Reference Guide – turns out they only apply in PHP4, though.

I’m still very impressed with Code Igniter, moreso now that the only problems I’ve encountered turned out to be my own stupidity rather than a failing of the framework.

Filed under: PHP.

Technorati tags:

Digg this article

Bookmark this article with del.icio.us

Previously: Code Igniter hates my server

Next: New Job


Comments

Yannick
812 days ago
Glad you were able to fix the problem Matthew. By chance what you were working on, wouldn’t have been the voting system for BiteSize Standards would it?
#1
leslie
812 days ago
Hi Matthew,

I’m curious about what you used CI for as well. Was it the BitSize Standards voting system?
#2
Matthew Pennell
811 days ago
Yes, it was the new Bite Size Standards article queue/voting system – I’d been looking for an excuse to use CI (and putting off building something useful like an ecommerce app), so when John asked for something to manage the approval process it seemed like a good opportunity to give it a whirl.

What I like is the enforced modularity of your functionality, so if I need to add something like cookie or session management at a later date it will be easy.
#3
Yannick
811 days ago
Oh okay cool. Yeah that is one of the nice things about CI being able to add things if/when they are needed and it’s a cinch to add in too.
#4