i think one problems is having all that code in a while loop. possibly a problem with register globals too.
see if this code will work
<?php
include("config.php");
// Check if blocked
$blocked = FALSE;
mysql_query("USE " . $dbname . ";");
$result = mysql_query("SELECT ip FROM blocked;");
while($query_data = mysql_fetch_row($result))
{
if ($query_data[0] == $ip)
{
$blocked = TRUE;
break;
}
}
if($blocked == TRUE) {
header("Location: index.php?msg=You cannot post a shout at this time beacuse your computer has been blocked, if you think this is in error please email [email]tom@sk8bstoke.co.uk[/email]");
} else {
// Check for validity
if ($_POST[nick] == "" OR $_POST[shout] == "")
{
header("Location: index.php?msg=Both fields must be completed!");
} else {
$date = date(Y) . "-" . date(m) . "-" . date(d);
mysql_query("USE $dbname;");
mysql_query("INSERT INTO $tblname (nick, shout, created, ip) VALUES ('$nick', '$shout', '$date', '$ip');");
header ("Location: index.php?msg=Shout Added!");
}
}
?>