Don’t You Love It When You’re Stupid?

Don’t you just love it when you spend hours banging your head against the wall trying to figure out why your code won’t work properly, only to find out it’s because you’re stupid? This seems to happen to me quite a bit.


I don’t know if it’s because I spend so much time switching back and forth between PHP, VBScript, JavaScript and Perl; if it’s because I don’t pay enough attention to what I’m doing; if it’s because I don’t get enough rest or spend too much time in front of the computer screen; or if it’s just because I really am stupid sometimes.

The most recent example I can think of happened just the other day. I spent three evenings working on trying to update the code for CAGCMS, which is the content management system (CMS) that I’m writing in PHP. I kept running into a roadblock over and over again.

I had written some code that was supposed to determine which page the user is viewing and mark that navigation link as active. I tested it, and it was marking all of my links as active. I looked over the code, tried to fix it, and tested it again. It still wasn’t working. I looked over the code again, and figured out that I had only used a single equal sign instead of the double equal sign (that is a direct result of switching back and forth between VBScript and the other languages). “That fixed it,” I thought.

I tried it again. I was wrong. That hadn’t fixed it. I changed and changed the code, and I tested and tested it over and over again. I still couldn’t figure out why it wasn’t working.

I finally came across the reason behind all of my troubles: I had written my code so that it set the opening and closing “active” tags to the same value whether the link really was active or not.

My code was supposed to look something like:
if($id == $rs[id]) {
$opentag = $act_open;
$closetag = $act_close;
}
else {
$opentag = "";
closetag = "";
}

Instead, I written my code like this:
if($id == $rs[id]) {
$opentag = $act_open;
$closetag = $act_close;
}
else {
$opentag = $act_open;
$closetag = $act_close;
}

Don’t you just love it when you overlook something simple like that, and it takes you an eternity to figure that out?

I just thought I would share my latest experience in stupidity. Feel free to share any experiences you’ve had like that.

HTMLCenter, , , , , stupid mistakes

Did you like this post? Get monthly summary of our new tutorials, posts and tips to your inbox!

No Responses

Post Your Comment

Your email address will not be published.