Its the Simple Things

I am still working forward on the Facebook integration and resume stuff. And will get that posted when I have completed the data model and the basic set up. I will also post about how to integrate Facebook into a CakePHP application. But in the mean time, there was something that happened, that I thought may help me remember.

The other day I was working on an application with a simple login check and display of an error message. I would test the login function with a correct account and an incorrect account. It was driving me batty as when I logged in with wrong credentials, it would not give me the message that something was wrong. I was checking everything. I checked the controller, the model and the view. Could not pin point the issue. I could not find anything wrong. Here is what I had in the view:

if ($sess->check(errors)) {
    $sess->errors);
}

Basically, if the login is incorrect, it will set an error. The session object will read any errors, set the item in the session to display once, and then kill the error so it does not keep happening. And here is the problem, in another application using the same basic code it works fine. Could not pinpoint why this is a problem here. Until I took a brief walk away from the desk. Then I came back and understood what I needed to do.

The check function does not do any displaying of any kind. It is supposed to check the session for errors, and destroy the session element with the errors. Before it does that, it sets a variable for the errors. However, it does not display. I needed to alter it to this:

if ($sess->check(errors)) {
    echo $sess->errors);
}

And there it was! Wow, the littlest thing. I am reminded of a Simpsons episode in which Hank Scorpio tells Homer:
“Well, you can’t argue with the little things. It’s the little things that make up life.”

Indeed it does.