我是PHP的新手,无法通过检查类似的问题来解决这个问题。
<?php
function charAt($str, $pos)
{
return $str{$pos};
}
$servername = "localhost";
$username = 'root';
$password = '';
$dbname = 'shop';
$conn = new mysqli($servername, $username, $password, $dbname)
or die ("Unable to connect");
$c_number = $_POST['c_number'];
$c_name = $_POST['c_name'];
$c_surname = $_POST['c_surname'];
$c_address = $_POST['c_address'];
$c_tnumber = $_POST['c_tnumber'];
$sql = "UPDATE customers SET c_name = ". $c_name . " WHERE c_number = " . $c_number;
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
我收到的消息是: 更新记录时出错:未知栏&#39;布莱恩&#39;在&#39;字段列表&#39;
如果我这样写的话,效果很好:
$sql = "UPDATE customers SET c_name = 'Bryan' WHERE c_number = " . $c_number;
提前谢谢