Accomplished!

I’ve spent the past 5 hours pounding my head against the desk trying to self-teach myself everything about PHP sessions, objects, and MySQL accesses all at the same time by building the login/registration portion of my webapps final project. But hey, it was all worth it, because I understand them now!

The more I do webapps stuff, the more I think this is what I want to do with my life. I can’t identify what it is about writing PHP (or, to a certain extent, JSP or Java Servlet) code that is so addicting… but once I start, I just can’t stop. I can’t tell you how many times I’ve found myself sitting at my computer until $late_hour writing webapp code… and that rarely happens with any other kind of program.

So yeah, I spent a while trying to fix mistakes that came about from misunderstandings about PHP (trying to teach yourself 3 new things at once doesn’t make it easier to learn any one of them)…
-The header() function doesn’t automatically dispatch. You must call exit afterwards if you want to immediately dispatch the headers (ex: redirect to a new page).
-Starting a session (with session_start()) automatically calls in all saved session variables, overriding any existing variables. I couldn’t figure out why the hell $username was being overridden until I realized I hadn’t lost my previous session (which contained a duplicate $username variable), and it was loading the variables.
-You cannot use session_unset() if you set variables through $_SESSION
-If a function returns either an object or false, you cannot do testing with !$variable, you must do $variable!=false (but you can do that with functions that return either true or false).
-Defining things with define() in an if statement doesn’t carry over into the global scope (although this problem might have stemmed from one of the previous misunderstandings).
-The general hash() and hash_hmac() functions are only in PHP5, and my server only has PHP4.
But hey, I got everything working… now I can start on the fun part.

I really should be asleep given that I have class tomorrow at 7:30 followed by an exam. Blah at that.

It’s a Todd! For some reason I like this picture a lot.

One thought on “Accomplished!

  1. Gotta love tha web apps. I have a PHP/mySQL O’reilly book sitting on my bookshelf, just crying out for a free weekend design project.

Comments are closed.