PHP: cannot pass single quoted string to mysqli query -


i fighting hours thing:

$var=var;     $result = "select column1, column2 $db column3 = '$var' "; 

the error is: have error in sql syntax; check manual corresponds mysql server version right syntax use near '\'var\'' @ line 1

names correct, works in mysql query. think tried possible quoting options, wrong?

update: requested used escaping, error remains same

$var=var;    $var = $conn->real_escape_string($var); $result = "select column1, column2 {$db} column3 = '{$var}' "; 

there must

$var = $mysqli->real_escape_string($var); $sql = "select column1, column2 {$db} column3 = '{$var}' "; 

instead of:

$result = "select column1, column2 $db column3 = '$var' "; $result = $mysqli->real_escape_string($result) ; //totally wrong. 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -