Stupidest Error
Moderator: General Moderators
Stupidest Error
We've all done it; we stay up until 12 or so at night to finish a project. We then run/test it and find we have an error. And yet no matter how much we look through our complicated classes and scripts; we just CANT find the error.
So you get up and get a cup of coffee, but as soon as you sit down you realize "Ah <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> I forgot a parentheses!".
How many times does that happen to you and what form do the errors take?
So you get up and get a cup of coffee, but as soon as you sit down you realize "Ah <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> I forgot a parentheses!".
How many times does that happen to you and what form do the errors take?
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Missing a bracket off statements like this
I always always do that!
Also semi colons
Code: Select all
if(!empty($somVar)Also semi colons
Ditto. But it takes like 2 seconds to fix after reading the parse error.Pimptastic wrote:Missing a bracket off statements like this
I always always do that!Code: Select all
if(!empty($somVar)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Syntax errors, notices, warnings etc I always fix in like 10 seconds. You can't possibly require a coffee for those errors because you should be using an editor that highlights them and also have full error reporting on PHP.
Logic errors.... those can drive you nuts and yes, a cup of coffee and some time away from the computer doing something compltely unrelated usually helps... sometimes you need to clear your head when you've started looking down the wrong path.
Logic errors.... those can drive you nuts and yes, a cup of coffee and some time away from the computer doing something compltely unrelated usually helps... sometimes you need to clear your head when you've started looking down the wrong path.
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
oh no doubt.d11wtq wrote:Syntax errors, notices, warnings etc I always fix in like 10 seconds. You can't possibly require a coffee for those errors because you should be using an editor that highlights them and also have full error reporting on PHP.
Logic errors.... those can drive you nuts and yes, a cup of coffee and some time away from the computer doing something compltely unrelated usually helps... sometimes you need to clear your head when you've started looking down the wrong path.
if it's been longer than 2 days for any logic error my personal choice is to start all the way over lol
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Same.MrPotatoes wrote:oh no doubt.
if it's been longer than 2 days for any logic error my personal choice is to start all the way over lol
I take a similar stance when it comes to improving other people's code. I'll tend to overview what it does then write my own rather than taking the exisiting code and modifying it. A clean start is always good.
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
i've tried. i've honestly tried to modify other peoples' code and it usually ends up terribly and i never learn my lesson.
very few times have i successfully worked with other peoples' code. i tend to see what it does and make a much more simpified version. my template is the only system that i have re-coded and working successfully.
very few times have i successfully worked with other peoples' code. i tend to see what it does and make a much more simpified version. my template is the only system that i have re-coded and working successfully.
Here is how I deal with the
error - through strict white space:
Make sure the function has no whitespace in the params list, and the if parens always has a space after and before the brackets.
Should save you about 3-4 seconds.
Code: Select all
if(!isset($var)
die;Code: Select all
if ( ! isset($var) )
die;Should save you about 3-4 seconds.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
A good way to prevent to extremely common assignment vs comparison issue:
is to place the constant on the left-hand side ... looks wrong though.
Code: Select all
//I mean
// if ($foo == 42)
if ($foo = 42)
{
//blah, always true of course
}Code: Select all
if (42 = $var) //Error... can't change value of constant 42
{
//
}- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US