Issue
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 :)
Solution
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
Answered By - Alexandre Tranchant
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.