PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 25, 2022

[FIXED] T_CONSTANT_ENCAPSED_STRING error.

 January 25, 2022     mysql, php, phpmyadmin, sql     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing