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());

}

it gives answer like this:-

DB initiated
Error:

What is the problem..?

4
  • WEHER is wrong it should be WHERE Commented Aug 6, 2013 at 9:10
  • You can use the built in mysql error function to get details if it was a query error php.net/manual/en/function.mysql-error.php Commented Aug 6, 2013 at 9:11
  • 1
    You're mixing mysql_ and mysqli_ functions. Commented Aug 6, 2013 at 9:15
  • Misspelling should be encountered by the author. Commented Aug 6, 2013 at 10:06

4 Answers 4

1

The WHERE is spelt incorrectly as WEHER:

Try this

$sql="UPDATE contactus SET address = '$address' , pincode = '$pincode' , phone = '$phone' , email = '$email' WHERE id='$id'";
Sign up to request clarification or add additional context in comments.

Comments

1

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'"

Comments

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());

}

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());

}

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.