Hmm, what to say, most PHP projects I've ever seen are just plain horrible. I can't remember much, here goes:
// WARNING: Don't try this at home!
mysql_query("SELECT * FROM tblSomething WHERE id = " . $_GET['x'] . " AND tblSomethingElse = " . $someval ) or die(mysql_error());
(note, there is no return in this, SO wrapped it)
- Breaking 80 columns isn't cool anymore, let's break 120! Who knew that Moore's law applies to source line length?
die(mysql_error())
yay! let's spam the user with something that is completely useless to him instead of a standard not found page
"foo" . $bar . "baz"
ugly as...
$_GET['x']
Unsanitized, however I blame PHP for not forcing you to use parameterized queries.
or die()
wtf, maybe for a 10-line project it's okay to die in the middle of nowhere
If you're going to do something insecure, at least make the code look nice..
mysql_query("SELECT * FROM tblSomething WHERE id = {$_GET['x']}".
"AND tblSomethingElse = $someval") or die(mysql_error());
What seems to be an idiom in php:
include($_GET['x']);
This is just plain bad security-wise, and bad programming style anyways.
Writing 500 function calls with the @
error suppressor.
Global variables galore. Setting $_GET['x'] = 123
, then calling a function with no parameters that uses $_GET['x']
which also calls another function with no parameters that uses $_GET['x']
.
People calling sprintf where they could have just used string interpolation.. uggh.
This:
<?php
if ($_GET['ad'] == 'ud') {
include('includes/ud.inc.php');
} else if ($_GET['ad'] == 'dd') {
include('includes/dd.inc.php');
} else if ($_GET['ad'] == 'wd') {
include('includes/wd.inc.php');
} else if ($_GET['ad'] == 'fd') {
include('includes/fd.inc.php');
} else if ($_GET['ad'] == 'cd') {
include('includes/cd.inc.php');
} else if ($_GET['ad'] == 'od') {
include('includes/od.inc.php');
} else if ($_GET['ad'] == 'ld') {
include('includes/ld.inc.php');
} else if ($_GET['ad'] == 'ldu') {
include('includes/ldu.inc.php');
} else if ($_GET['ad'] == 'ldc') {
include('includes/ldc.inc.php');
} else if ($_GET['ad'] == 'lde') {
include('includes/lde.inc.php');
} else if ($_GET['ad'] == 'pd') {
include('includes/pd.inc.php');
} else if ($_GET['ad'] == 'nd') {
include('includes/nd.inc.php');
} else if ($_GET['ad'] == 'cu') {
include('includes/cu.inc.php');
} else if ($_GET['ad'] == 'kg') {
include('includes/kg.inc.php');
} else if ($_GET['ad'] == 'st') {
include('includes/st.inc.php');
} else if ($_GET['ad'] == 'cm') {
include('includes/cm.inc.php');
} else {
include('includes/home.inc.php');
}
?>
And the winner is...
<table cellpadding="4" cellspacing="0" border="0">
<?php do { ?>
<?php if ($userDetails['name'] == 'adLinkTitle') { ?>
<tr>
<td>
<label for="wTitle">Your Website Title:</label>
</td>
<td>
<input name="wd_title" type="text" id="wTitle" class="adminInput" value="<?php echo $userDetails['value'];?>" />
</td>
</tr>
<?php } ?>
<?php if ($userDetails['name'] == 'adLinkURL') { ?>
<tr>
<td>
<label for="wAddress">Your Backlink URL:</label>
</td>
<td>
<input name="wd_url" type="text" id="wAddress" class="adminInput" value="<?php echo $userDetails['value'];?>" />
</td>
</tr>
<?php } ?>
<?php if ($userDetails['name'] == 'adLinkDescription') { ?>
<tr>
<td>
<label for="wAddress">Your Website Description:</label>
</td>
<td>
<textarea name="wd_description" id="wDescription" class="adminInput" rows="6"><?php echo $userDetails['value'];?></textarea>
</td>
</tr>
<?php } ?>
<?php } while ($userDetails = mysql_fetch_assoc($getUserDetails)); ?>
</table>
<input type="hidden" name="wd_updated" value="yes" />
<input value="Update Your Link Details" type="submit" class="padSubmit" />
</form>
<br />