SQL UPDATE不更新我的表


SQL UPDATE not updating my tables

这是我当前的代码

$reg = $_REQUEST['reg'];
$vin_no = $_REQUEST['vin_no'];
$imei = $_REQUEST['imei'];
$sql="UPDATE client SET 
        reg = '$reg',
        imei = '$imei',
        vin_no = '$vin_no'
WHERE imei = '$imei'";
$result=mysql_query($sql);

IMEI已经完成了以前的数据,因此它不应该改变。其他列为空,Will UPDATE是此实例中的正确方法。目前,当我从表单页面发送信息时,它根本不更新SQL表。我在我的表单上使用POST,我确实从表单中获取数据。

我不确定这是代码的唯一问题,但要回答我认为你在问什么…

如果你不想改变IMEI字段作为UPDATE的一部分,那么就不要把它放在要更新的字段列表中,你只需要更新你正在更改的列,就像这样

我还添加了一些基本的调试建议,当然,如果你是在开发服务器上,你应该有错误报告,但以防万一你没有或正在LIVE服务器上工作…

// force some error reporting
error_reporting(E_ALL); 
ini_set('display_errors', 1);
$reg = $_REQUEST['reg'];
$vin_no = $_REQUEST['vin_no'];
$imei = $_REQUEST['imei'];
$sql="UPDATE client SET 
        reg = '$reg',
        vin_no = '$vin_no'
WHERE imei = '$imei'";
$result=mysql_query($sql);
// test the result of the update, show the error if it fails
if ( ! $result ) {
    echo mysql_error();
}