<?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:
问题是什么??
答案 0 :(得分: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'"
答案 1 :(得分: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());
}
答案 2 :(得分:0)
WHERE
拼写错误为WEHER
:
试试这个
$sql="UPDATE contactus SET address = '$address' , pincode = '$pincode' , phone = '$phone' , email = '$email' WHERE id='$id'";
答案 3 :(得分:0)
您是否在mysql_query函数中传递了“link identifier”参数?
resource mysql_query ( string $query [, resource $link_identifier = NULL ] )
我知道这不是强制性的,但是您正在使用mysql_query执行查询,使用mysqli获取错误,dbconfig我们无法看到它。 所以很难猜到。