Skip navigation.
Home

one wtf, two wtf, three wtf...ah ah ah!

Wonky Code

I had to confirm that this was production code. It's always more funny, or tragic, when production code is bad. Thanks to Søren for sending this in.

What's the most efficient way to skip a few numbers? Well it's not this way! It's bad enough that 2, 3 and 4 are literals and not constants, but they also represent database logic. At least they didn't select * and skip records with the wrong TypeId's.

<?php
// ...
    
if($TypeId>0) {
     if (
$TypeId == 2) {
     } else if(
$TypeId == 3) {
     }else if(
$TypeId == 4) {
     }
     else {
       
$sql .= " AND D.TypeId = $TypeId";
     }
   }
?>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Deary me!I have some others

Deary me!

I have some others to submit, but they're really terrible. As in good. *wierds*