mysql error Error updating record: You have an error in your SQL syntax;

Asked

Viewed 174 times

0

I’m having a problem with an update. of this mistake

string(42) " UPDATE files SET desc='ssss' WHERE id=131" Error updating record: You have an error in your SQL syntax; check the manual that Corresponds to your Mariadb server version for the right syntax to use near 'desc='ssss' WHERE id=131' at line 1

follows my code

 <?php
// Include the database configuration file
require 'conn/conn1.php';

$id_img = $_POST['id'];
$desc = $_POST['desc'];

$sql = " UPDATE files SET desc='$desc' WHERE id=$id_img";
var_dump($sql);

   if (mysqli_query($conn1, $sql)) {
      echo "Record updated successfully";
   } else {
      echo "Error updating record: " . mysqli_error($conn1);
   }
   mysqli_close($conn1);
?>

could you please help me!

1 answer

1

Good morning, apparently there is no concatenation between your sql string and your variable '.$variable. ', also if this variable is going to receive some string use '". $variable." '.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.