-2

I'm trying to update a value in my table, but i have a syntax-error and i can't find the error.

This is my php code:

$data = new MysqlClass();
$data->connect();

$result_sql = $data->query("UPDATE iscrizioni SET '".$matricola."' = 'si' WHERE 'COD'=".$cod);

it returns me:

You have an error in your SQL syntax; check the manual that corresponds  to your MySQL server version for the right syntax to use near ''805710' =  'si' WHERE 'COD'=1' at line 1

Have you any idea where the error is?

Thank you very much!

Matteo
  • 59
  • 1
  • 1
  • 5

1 Answers1

1

You are using column's names as strings, use ` instead of '. Or don't use it at all.

$result_sql = $data->query("UPDATE `iscrizioni` SET `".$matricola."` = 'si' WHERE `COD` = ".$cod);
Justinas
  • 41,402
  • 5
  • 66
  • 96