SQL错误(更新gegevens)::'字段列表'中的未知列'1'

时间:2013-12-08 13:30:15

标签: php mysql

我知道这是一个“众所周知”的问题,但我无法让它发挥作用。以下MySQL查询(在PHP中)给我这个错误

 $sqle = "UPDATE $gameID SET `$column` = `$vav` WHERE drank='$drank'";
 $resulte = mysql_query($sqle) or die('SQL Error (update gegevens):: '.mysql_error());

我尝试了很多不同的引用,但我无法让它发挥作用。有人能把我送往正确的方向吗?

也;

$column = 'prijs_max';
$vav = $INFO[$count+1];  // returning a number

编辑后的完整循环

$count = 0;
    foreach ($INFO as $value) {
        $column = "";
        if(strpos($value, '§') !== false) {
            $pieces = explode('§', $value);
            $drank = $pieces[0];
            $rang = $pieces[1];

            if ($rang == 'start') {
                $column = 'prijs_start';
            } elseif ($rang == 'min') {
                $column = 'prijs_min';
            } elseif ($rang == 'max') {
                $column = 'prijs_max';
            }

            if ($column == 'prijs_start') {
                $bidmaxquery = "SELECT drank FROM $gameID WHERE drank = '$drank'";
                $bidmax = mysql_query($bidmaxquery) or die('SQL Error (get drank) :: '.mysql_error());

                if (mysql_num_rows($bidmax) == 0) {
                    $vav = $INFO[$count+1];
                    $inc = $INFO[$count+7];
                    $sqld = "INSERT INTO $gameID (drank,$column,prijs_current,increment) VALUES ('$drank','$vav','$vav','$inc')";
                    $queryd = mysql_query($sqld) or die('SQL Error (insert eerste gegevens):: '.mysql_error());
                }
            } else {
                $vav = $INFO[$count+1];
                echo $vav;
                echo "<br>";
                $sqle = "UPDATE $gameID SET `".$column."`=$vav WHERE drank='$drank'";
                $resulte = mysql_query($sqle) or die('SQL Error (update gegevens):: '.mysql_error());
            }

        }
        $count ++;
    }

2 个答案:

答案 0 :(得分:1)

尝试

"UPDATE $gameID SET `".$column."`='$vav' WHERE drank='$drank'";

答案 1 :(得分:0)

"UPDATE $gameID SET $column ='$vav' WHERE drank='$drank'";