Wednesday, 28 August 2013

Why MySQL is changing the column name with value?

Why MySQL is changing the column name with value?

I have the 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 WHERE DriverId=3
However when I run
$result = mysqli_query($con2,$sql);
echo $result;
echo mysqli_error($con2);
I get
Unknown column 'locA' in 'field list'
Why am I getting 'locA' instead of Location as column name ?

No comments:

Post a Comment