Reputation: 23
<?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());
}
it gives answer like this:-
DB initiated
Error:
What is the problem..?
Upvotes: 1
Views: 5244
Reputation: 1763
$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());
}
should be
$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());
}
Upvotes: 1
Reputation:
Use a correct mysqli syntax. here an example
<?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);
?>
source: http://www.w3schools.com/php/php_mysql_update.asp
And fix you query
WEHER id='$id'";
by
WHERE id='$id'"
Upvotes: 1
Reputation: 14731
Are you passing the "link identifier" parameter in mysql_query function?
resource mysql_query ( string $query [, resource $link_identifier = NULL ] )
i know is not mandatory, but you are executing query with mysql_query, getting the error with mysqli, dbconfig we cannot see it. So is difficult to guess.
Upvotes: 0
Reputation: 8818
The WHERE
is spelt incorrectly as WEHER
:
Try this
$sql="UPDATE contactus SET address = '$address' , pincode = '$pincode' , phone = '$phone' , email = '$email' WHERE id='$id'";
Upvotes: 1