-1

Hello, I'm very new to PHP and im getting this error...:

Parse error: syntax error, unexpected ''arak'' (T_CONSTANT_ENCAPSED_STRING) in /testSQL.php on line 6

...for this line:

$query = UPDATE 'arak' SET `ara` = '$ar1' Limit 0,1;

A little help would be appriciated :)

1 Answers1

0

You have to quote the string by ", protect the table name by ` and protect value with '

$query = "UPDATE `arak` SET `ara` = '$ar1' Limit 0,1";

Be careful, $ar1 must be protected. For example, if $ar1 = '33\'33', you could have problem.

$ar1 = addslashes($ar1);
$query = "UPDATE `arak` SET `ara` = '$ar1' Limit 0,1";

Addslashes is a first step to prevent SQL Injection, but it is not enough as you can read it

Community
  • 1
  • 1
Alexandre Tranchant
  • 4,426
  • 4
  • 43
  • 70