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
Post a Comment