<?php
$dbhost = 'localhost';
$dbuser = 'santhosh';
$dbpass = 'Santhu';
$database = 'car';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($database, $conn);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$name="nair";
$lat="123";
$lon="456";
$sql = "UPDATE cart SET latitude='$lat',longitude='$lon' WHERE uname<="$name";
if (mysql_query($sql)) {
echo "New record updated successfully";
} else {
echo "Error: " ;
}
mysql_close($conn);
?>
我收到消息&#34;错误&#34;这意味着我无法更新我的表格。请告诉我我的代码中有什么错误...先谢谢你
答案 0 :(得分:0)
请更改您的查询,如下所示。
"UPDATE cart SET latitude='$lat',longitude='$lon' WHERE uname = '".$name."'";
我希望这会对你有所帮助
答案 1 :(得分:0)
我认为查询会像这样
$sql = "UPDATE `cart` SET `latitude`='".$lat."',`longitude`='".$lon."' WHERE `uname`='".$name."'";
答案 2 :(得分:0)
<?php
$dbhost = 'localhost';
$dbuser = 'santhosh';
$dbpass = 'Santhu';
$database = 'car';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($database, $conn);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$name="nair";
$lat="123";
$lon="456";
$sql = "UPDATE cart SET latitude='$lat',longitude='$lon' WHERE uname='$name'";
if (mysql_query($sql)) {
echo "New record updated successfully";
} else {
echo "Error: " ;
}
mysql_close($conn);
?>
答案 3 :(得分:0)
您的查询中有一个错误引用的错误。
"UPDATE cart SET latitude='$lat',longitude='$lon' WHERE uname<=$name";
^^^^^^^^
更新了查询
"UPDATE cart SET latitude = '$lat',longitude = '$lon' WHERE uname = '".$name."'";
^^^^^^^^^^^^^^
答案 4 :(得分:0)
$sql = "UPDATE cart SET latitude = '$lat',longitude='$lon' WHERE uname = '".$name."'";
这段代码解决了我的问题。 谢谢大家的答案......