I have a PHP sql command that updates a record.
$tsql = "UPDATE cplinktable SET bmsid = $bmsid, autotaskid = $autotaskid, waspdb = $waspdb, cpid = $cpid WHERE id = $id";
I'm getting an error:
Invalid column name 'WaspTrackAsset_SFT'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name 'WaspTrackAsset_SFT'. ) )
Is there some reason that the value of waspdb is being used as a column?
thanks,
Jonesy
Its a string field or varchar probably and you need it in single quotes. Like this:
$tsql = "UPDATE cplinktable SET bmsid = $bmsid, autotaskid = $autotaskid, waspdb = '$waspdb', cpid = $cpid WHERE id = $id"
If the variable is a string, SQL requires single quotes around it:
waspdb = '$waspdb'
Otherwise, it will look in the source row for a column with the name of the value of $wasdb
. The reason why is perhaps most clearly illustrated with an example query:
update YourTable set col1 = 2*col2
This multiplies col2
by 2
; it doesn't set col1
to '2*col2'
:)