2011-04-08 90 views
0

我得到這個錯誤:在 未知列'理查德「where子句」在此代碼 :mysql的更新錯誤

if(isset($_POST['Zabanovat'])){; 
    $nick = $_POST['nick']; 
    $ban = $_POST['ban']; 
    mysql_query("UPDATE TABLE Set usr_unban = $ban WHERE usr_nick = $nick ") OR die(mysql_error()); 
} 

echo "<form method=\"post\">"; 

echo "<div class=\"formatLabel\"><label for=\"nick\"><h2>Zadejte jméno banovaného účtu</h2></label></div>"; 
echo "<div class=\"formatContent\"><input type=\"text\" id=\"nick\" name=\"nick\"></div>"; 

    echo "<div class=\"formatLabel\"><label for=\"ban\"><h2>Zadejte datum unbanu (dd.mm.yyyy)</h2></label></div>"; 
echo "<div class=\"formatContent\"><input type=\"text\" id=\"ban\" name=\"ban\"></div>"; 

echo "<div class=\"formatSubmit\"><input type=\"submit\" value=\"Zabanovat\" name=\"Zabanovat\"></div>"; 

echo "</form>"; 
+1

yikes。 http://php.net/manual/en/function.mysql-real-escape-string.php – 2011-04-08 17:33:32

回答

0

如果變量不包含數字值,則必須將變量放在單引號內。

mysql_query("UPDATE TABLE Set usr_unban = '$ban' WHERE usr_nick = '$nick'") OR die(mysql_error()); 
0

我覺得鍵入查詢時你缺少表名,除非你的表被命名爲 「表」:

mysql_query("UPDATE TABLE Set usr_unban = $ban WHERE usr_nick = $nick ") OR die(mysql_error()); } 

應該是:

mysql_query("UPDATE **TABLE_NAME** Set usr_unban = $ban WHERE usr_nick = $nick ") OR die(mysql_error()); } 

remembe r,SQL中的UPDATE類是:

UPDATE "table_name" 
SET "column_1" = [new value] 
WHERE {condition}