1
<?php
include 'dbConfig.php';
$address=mysql_real_escape_string($_POST['address']);
$pincode=mysql_real_escape_string($_POST['pincode']);
$phone=mysql_real_escape_string($_POST['phone']);
$email=mysql_real_escape_string($_POST['contactemail']);
$id=1;
$sql="UPDATE contactus SET address = '$address' , pincode = '$pincode' , phone = '$phone' , email = '$email' WEHER id='$id'";
$result=mysql_query($sql);
if (!$result)
{
    die('Error: '. mysqli_error());

}

它给出了这样的答案:-

DB initiated
Error:

问题是什么..?

4

4 回答 4

1

使用正确的 mysqli 语法。这是一个例子

<?php
$con=mysqli_connect("example.com","peter","abc123","my_db");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

mysqli_query($con,"UPDATE Persons SET Age=36
WHERE FirstName='Peter' AND LastName='Griffin'");

mysqli_close($con);
?>

来源:http ://www.w3schools.com/php/php_mysql_update.asp

并修复您的查询

 WEHER id='$id'";

经过

WHERE id='$id'"
于 2013-08-06T09:09:46.917 回答
1
$sql="UPDATE contactus SET address = '$address' , pincode = '$pincode' , phone = '$phone' , email = '$email' WEHER id='$id'";
$result=mysql_query($sql);
if (!$result)
{
    die('Error: '. mysqli_error());

}

应该

$sql="UPDATE contactus SET address = '$address' , pincode = '$pincode' , phone = '$phone' , email = '$email' WHERE id='$id'";
$result=mysql_query($sql);
if (!$result)
{
    die('Error: '. mysql_error());

}
于 2013-08-06T10:02:03.510 回答
0

拼写WHERE错误为:WEHER

尝试这个

$sql="UPDATE contactus SET address = '$address' , pincode = '$pincode' , phone = '$phone' , email = '$email' WHERE id='$id'";
于 2013-08-06T09:10:23.763 回答
0

您是否在 mysql_query 函数中传递“链接标识符”参数?

resource mysql_query ( string $query [, resource $link_identifier = NULL ] )

我知道这不是强制性的,但是您正在使用 mysql_query 执行查询,使用 mysqli 得到错误,dbconfig 我们看不到它。所以很难猜。

于 2013-08-06T09:18:42.673 回答