|



Menu separator

Français Français - Français
Français Français - English

Kzeon badge

Propulsé par...

Get Firefox !
Get Apache !
Get PHP !
Get MySQL !
XHTML

Nouvelles sur kzeon.com...

Pages : 1 2 3 4 5  >  >>> (5 pages)

Kzeon
avatar
Le 2009/05/08 à 21:21:53 .:. Why I hate generating HTML with for loops

Why I hate generating HTML with for loops.

So, today, a nasty but stupid bug... Ok so, basically, I have a website into which some HTML get generated on the fly, according to some elements from the database. Cool design, cool feature, but uncool modification in my code that... broke my whole graphic design. What happenned ? My whole design got totally messed up, couldn't find why, for half an hour.

Instead of looking directly into the html output (kinda log), I obviously check in the code first, making sure that all my opening div elements matches my closing div elements.

Positive.

Hmmm, probably then a small typo, somewhere.

Couldn't find any. What else ? Then, we'll go for the safe path, making a copy of my file, and then remove all the junk code that will not altere the output. After several minutes, paying attention to make sure I wouldn't remove anything important, I realized that my whole website structure was totally ok. What the hell was going on...

Then... oh, snap... while taking away smoothly the useless opening div tags, I realized that a closing tag was... inside a loop. Obviously, causing the visual inspection of the code to be perfect, unless you look at where the elements we're closed relatively to the loop. I then finally grepped and count my html output to... ya... realized that I had a lot of closing div in comparison with the other closing div... Ya, stupid. Quickly went to the code and realized that a closing div was INSIDE a for loop...

TGIF and thanks God I did waste this time at my place rather than at the office today, ahah.

Final word ? Application and server logs are more than useful. I usually spend a lot of time debugging my stuff at work using logs, but omitted to do a visual inspection of my HTML output before investigating like crazy for my problem. Actually, I would have seen the bug pretty quickly if I had done so.

This is NOT a signature

Commentaire :: 0 commentaire











""The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." - Edsger Dijkstra"