Php Mysqli没有更新数据库中的数据

时间:2014-08-04 01:27:22

标签: php mysql database mysqli

这是我的代码,它工作正常,没有错误弹出,并且变量的正确数据存在。

当它全部完成时,它显示完成最后一个回声。

但是,当我进入heidisql查看数据库表时,即使我在heidisql中运行查询,也没有任何变化,但结果仍然相同。

// Make connection to database
$connection = mysqli_connect($host,$user,$pass,$dbnm);
// Make query
$myQuery = "
    UPDATE Ekhaya_Inventory SET 
        ekhaya_inventory_stock_item = '" . $stockItemPost . "',
        ekhaya_inventory_stock_left = '" . $stockLeftPost . "',
        ekhaya_inventory_stock_out = '" . $stockOutPost . "',
        ekhaya_inventory_stock_minimum = '" . $stockMinimumPost . "',
        ekhaya_inventory_stock_price_per_item = '" . $stockPricePIPost . "',
        ekhaya_inventory_value_of_stock_left = '" . $stockValueOfStockLeftPost . "' 

        WHERE
            ekhaya_inventory_stock_code = '" . $stockCodePost . "' 
        AND
            ekhaya_inventory_stock_code = '" . $stockLocationPost . "'
";

mysqli_query($connection,$myQuery)or die("Error: ".mysqli_error($connection));
mysqli_close($connection)or die("Error: ".mysqli_error($connection));
echo "<br>Done";

1 个答案:

答案 0 :(得分:0)

WHERE
            ekhaya_inventory_stock_code = '" . $stockCodePost . "' 
        AND
            ekhaya_inventory_stock_code = '" . $stockLocationPost . "'

这是错误的,因为一个字段在同一时间内不能包含两个不同的值