php - Why MySQL is changing the column name with value? -


i have following piece of code written somewhere in php:

$sql="update drivers ". "set location=$lo ". "where driverid=$id";  echo $sql; 

the outcome of echo is

update drivers set location=loca driverid=3

however when run

$result = mysqli_query($con2,$sql); echo $result; echo mysqli_error($con2); 

i

unknown column 'loca' in 'field list'

why getting 'loca' instead of location column name ?

loca string , needs quoted.

$sql="update drivers ". "set location='$lo' ". "where driverid=$id"; 

you should using pdo , prepared statements quoting you.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -