SQL 更新无效
SQL UPDATE not working
我正在尝试更新名为 customer 的数据库中的一些数据。这是我的代码
<?php
Require("dbconnect.php");
$Customer_id = $_POST['Customer_id'];
$Customer_title = $_POST['Customer_title'];
$Customer_forename = $_POST['Customer_forename'];
$Customer_surname = $_POST['Customer_surname'];
$Customer_contact = $_POST['Customer_contact'];
?>
所有变量都保存着正确的数据,因为我已经测试过它们。
当我 运行 这段代码时没有收到任何错误,但是它也没有更新数据库?谁能帮忙?提前致谢!
字符串常量需要单引号(名字和姓氏):
$sql = "UPDATE `a6123854_a220559`.`Customer`
SET Customer_forename = '".$Customer_forename."', Customer_surname = '".$Customer_surname."'
WHERE Customer_id = ".$Customer_id."";
请注意,您的代码可能容易受到 SQL injection.
的影响
有一件小事很可能会解决您的问题。在报价单里。
$sql = "UPDATE `a6123854_a220559`.`Customer`
SET Customer_forename='".$Customer_forename."',
Customer_surname='".$Customer_surname."'
WHERE Customer_id='".$Customer_id."'";
我正在尝试更新名为 customer 的数据库中的一些数据。这是我的代码
<?php
Require("dbconnect.php");
$Customer_id = $_POST['Customer_id'];
$Customer_title = $_POST['Customer_title'];
$Customer_forename = $_POST['Customer_forename'];
$Customer_surname = $_POST['Customer_surname'];
$Customer_contact = $_POST['Customer_contact'];
?>
所有变量都保存着正确的数据,因为我已经测试过它们。 当我 运行 这段代码时没有收到任何错误,但是它也没有更新数据库?谁能帮忙?提前致谢!
字符串常量需要单引号(名字和姓氏):
$sql = "UPDATE `a6123854_a220559`.`Customer`
SET Customer_forename = '".$Customer_forename."', Customer_surname = '".$Customer_surname."'
WHERE Customer_id = ".$Customer_id."";
请注意,您的代码可能容易受到 SQL injection.
的影响有一件小事很可能会解决您的问题。在报价单里。
$sql = "UPDATE `a6123854_a220559`.`Customer`
SET Customer_forename='".$Customer_forename."',
Customer_surname='".$Customer_surname."'
WHERE Customer_id='".$Customer_id."'";