0

I am trying to update an entry in the database using html and php. However, I keep getting an error saying my sql syntax is wrong.

Here is the code from the php file:

<?php 
$server = "127.0.0.1";
$dbUsername = "root";
$dbPassword = "";
//create connection
$dbconn = new mysqli($server, $dbUsername, $dbPassword, $dbname);

 $email_follow = $_POST['email_follow'];
 $follow = $_POST['follow'];

 $update = mysqli_query($dbconn, "UPDATE CustomerDetails SET Follow Up = '$follow' WHERE Email = '$email_follow'");

if ($dbconn->query($update) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $dbconn->error;
}
 ?>

Here is the html form:

<form action="cust_details_followup.php" method="post">       

Email:
<input type="email" name="email_follow" id="email_follow">

Enter Follow Up Details:
<input type="text" name="follow" id="follow">


<input type="submit" value="Update">

</form>

Any help is appreciated. Thank you!

zaveriraj2
  • 37
  • 5
  • Possible duplicate of [When to use single quotes, double quotes, and back ticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-back-ticks-in-mysql) – Qirel Jun 25 '18 at 04:26

3 Answers3

2

You table property Follow Up has a space,you need to add ` to wrap it

So change

UPDATE CustomerDetails SET Follow Up = '$follow' WHERE Email = '$email_follow'

to

UPDATE CustomerDetails SET `Follow Up` = '$follow' WHERE Email = '$email_follow'
flyingfox
  • 13,414
  • 3
  • 24
  • 39
0

Need to use dot operator and need to use tick instead of single quote

Tick - Follow Up - Correct.

$query = "UPDATE CustomerDetails
    SET `Follow Up` = '".$follow."'
    WHERE Email = '".$email_follow."'";

$update = mysqli_query($dbconn, $query);
munsifali
  • 1,732
  • 2
  • 24
  • 43
0

Give a try with below code

UPDATE CustomerDetails SET `Follow Up` = '".$follow."' WHERE Email = '".$email_follow."'
shubhangee
  • 529
  • 3
  • 10