Your dumbest PHP mistakes
07-27-2004, 08:26 PM
|
Your dumbest PHP mistakes
|
Posts: 3,110
Location: Toronto, Ontario
|
Let's bring a little humor in the PHP forum  What is the dumbest mistake you've ever made when coding a PHP app?
Mine is probably when I was creating a file-upload script with multiple fields. I had a loop to loop through the fields, but I did it wrong. Instead, the script was copying the same first field over and over again until the script timed out (30 secs). (The nature of the script was to name the file based on the current time, so it wasn't overwriting the same file either, I had hundreds of the one file. Sucked.)
|
|
|
|
07-27-2004, 08:36 PM
|
|
Posts: 2,536
Location: Western Maryland
|
Yea, that's pretty good, Chroder. I don't think I can top that one.
But my biggest problem is forgetting to declare a variable global if I need to do so and of course the value never comes out right because you're starting from zero instead of some value. I have spent hours debugging and chasing one missing global.
__________________
—Kyrnt
|
|
|
|
07-27-2004, 08:38 PM
|
|
Posts: 3,110
Location: Toronto, Ontario
|
You don't use E_ALL as your error_reporting?  Saves countless hours of debugging.
|
|
|
|
07-27-2004, 08:44 PM
|
|
Posts: 2,536
Location: Western Maryland
|
No, I don't. I just fired up Apache one day and started playing with PHP. Bought a functions book and everything else is pretty straightforward. For anyone who has programmed at all, there's no need for an "Intro to PHP", IMO.
What is the basic premise of E_ALL error reporting?
__________________
—Kyrnt
|
|
|
|
07-27-2004, 08:47 PM
|
|
Posts: 3,110
Location: Toronto, Ontario
|
It reports almost everything. The thing I find most handy is when it compains about the use of an undefined variable. So if I used $bar = $foo + 1; but $foo didn't exist, it'd let you know. See here for an overview (and you can change it during the script with error_reporting(), you don't need to edit php.ini).
|
|
|
|
07-27-2004, 08:52 PM
|
|
Posts: 2,536
Location: Western Maryland
|
Thanks, Chroder, for the info & link -- I will take a look.
Sorry I ruined your thread..... 
__________________
—Kyrnt
|
|
|
|
07-27-2004, 09:19 PM
|
|
Posts: 3,189
|
The stupidest thing I have ever done is probably...
When I was reading through tutorials and came across one of those, "This is what not to do with loops" type of tutorials. Well, I was curious about the effects of
PHP Code:
<?php
$var = 1;
while($var < 2) {
$var++
}
?>
Needless to say I got an angry letter from my host at the time who, for some dumb reason, had their script timeout set to 2 minutes. The server went down before that though.
|
|
|
|
07-27-2004, 10:02 PM
|
|
Posts: 3,110
Location: Toronto, Ontario
|
lol I think we've all run into an endless loop at least once in our lives  (Mine was on purpose though, back in grade 6 when I made an endless loop in C++ and called it a "virus"  )
|
|
|
|
07-28-2004, 01:00 AM
|
|
Posts: 3
|
how about a stupid mysql msitake?
i was defining a table for counter-strike profiles and it took me about an hour to realize my field for favorite primary weapon defined as "primary varchar(25)" was interpreted as looking for a PRIMARY KEY.
|
|
|
|
07-28-2004, 01:10 AM
|
|
Posts: 3,110
Location: Toronto, Ontario
|
Stupid mysql mistakes are welcome too
I've had my share of those too. For example, just the other day I was looking over 13 lines of a "SELECT" SQL query trying to find an error. It was the next day I realized I had completely forgot to include the FROM clause. In my defense, it was 3:30 in the moning 
|
|
|
|
10-31-2004, 09:01 PM
|
|
Posts: 612
|
My dumbest mistake was this...
I was converting an VBScript (ASP) function to PHP.
In VBS, the function returns are like this
Code:
Function MyFunc()
Dim i
i = 25
MyFunc = i
End Function
You know that PHP functions are returned not like above...
Code:
function myfunc()
{
$i = 25;
return $i;
}
After converting all the lines in the VBS to PHP, i just forgot to see the return statement.
That caused buffer overflow and crashed PHP. I was running it in CGI mode.
It took me 2 weeks to figure out that mistake.
That was an important lesson for me.
Last edited by vivekar; 10-31-2004 at 09:04 PM..
|
|
|
|
10-31-2004, 10:28 PM
|
|
Posts: 303
|
This isnt too big a mistake, but back in the day it puzzled me,
Using capital letters for variables and wondering why it wouldnt work.
Syntax's normally cause me a phew problems 
Used to think IF statements MUST have } else { or they wont work.
eg. IF ($var = 1) {
echo('hahha');
}
(I thought was impossible)
Mistakes other people have done.
Tried to make a php page without the file extenstion .php and wondering why it wont work.
My webdesign partner changed the password of the database (I was away for the long weekend (3days), he doesn't know php too well), I get back and he is having a " stroke" saying "The database is fuc*ed , It's crashed, make a new one!, the site has been down for 3 days! We will lose our affiliates "
Took me 5 minutes to find out that he had changed the database password.
__________________
Websites Created;
warscope.com
ratepayers.org.nz
|
|
|
|
11-01-2004, 10:05 AM
|
|
Posts: 25
|
I was working with drupal and couldn't track down this one bug that was spitting out an "e" at the top of the page. A week later I noticed that the file (a custom theme module) started with "e<?php". Retarded
|
|
|
|
11-01-2004, 12:14 PM
|
|
Posts: 303
|
(I mean no offence, it just made me laugh when i first read it)
__________________
Websites Created;
warscope.com
ratepayers.org.nz
|
|
|
|
03-13-2005, 11:35 AM
|
|
Posts: 130
Location: Atlanta, Georgia
|
HaHa! Imagine if we laughed about these things in the real world, everyone would call us nerds and whatnot for having programmatical laughter, LOL!
My most retarded mistake, was when I was trying to rename pictures before they got uploaded, added the time and converting spaces to underscores... Well, for some reason, it would tell me I had an incorrect filetype (An error I programmed in). About 3 days later, I realized that variables can't begin with a number! That F'ing sucked! LOL
__________________
Please login or register to view this content. Registration is FREE - For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.
|
|
|
|
03-13-2005, 02:36 PM
|
|
Posts: 1,832
Location: Somewhere else entirely
|
Was editing a script the other day to add some text to a certain page in my site. Most things are included() into each page, but this text needed to be on the border, so I edited the layout file. I somehow messed up the conditional of which page to print the text on, so that it worked, but broke some image links I already had there. These were the links to an online application form for May Ball tickets, and I got frantic email telling me it was broken.
I then went back in and changed the conditional so they reappeared. What I didn't realise until later was that I'd got it wrong again, so that the links now appeared on ALL the pages on the site!! The third time round I finally fixed it!
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Please login or register to view this content. Registration is FREE (aka MSN handwriting for forums)
|
|
|
|
03-13-2005, 03:12 PM
|
|
Posts: 397
Name: Steve
Location: Scotland
|
Oh the joys of our mistakes.
My funniest has to be the time my host nearly threw me off the server. I was creating a script that created 2 files in their own folder, one readable and one writable. To cut a long story short, I made the readable first and being the lazy bam that I am, I saved that file and then saved it as the writable too, with the intention of changing the permissions.
Only problem was I got sidetracked and when i got back to the PC, I forgot about it and uploaded the scripts. I then went to bed and in the morning had a nice wee email from my host with a copy of their logs - made for a great read over my corn flakes.
|
|
|
|
03-14-2005, 05:28 AM
|
|
Posts: 377
|
The dumbest mistake are usualyy missing quotes or brackets 
But I've got a funny mistake too yesterday. I've copied my API (well just simple engine) from one site to another site. Then I have to change an output of news a little (I'd like to trim a whole message to use it as annotation). I did it. But when I refreshed my window there were no result... I displayed all errors with E_ALL. But still nothing! I begin to doubt - who are crazy??? Me or PHP? 
I changed a file few times, but still nothing. And then I looked at my API config file and discovered that I didn't chage a path leading to displayed template, so that one which I've edited wasn't displayed at all - it loaded a template from another folder... 
|
|
|
|
03-14-2005, 05:57 AM
|
|
Posts: 80
|
The stupids mistake I've ever made was not saving a file and wondering why it wasn't working... I read the code like 5 times, then after about 20 reads I noticed it was missing...
__________________
Please login or register to view this content. Registration is FREE The future is now with 4D Realms
|
|
|
|
03-14-2005, 07:55 AM
|
|
Posts: 880
Location: Leeds UK
|
Has to be when i emailed the wrong message out for a competition.
Everyones a winner.
Thank god only 100 odd played (most of whom accepted the mistake) but I had 1/2 dozen or so chasing freebie's.
Lesson learned and 4 years on no mistakes.
Ibbo
|
|
|
|
|
« Reply to Your dumbest PHP mistakes
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|