0

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

2 Answers 2

3

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' :)

Sign up to request clarification or add additional context in comments.

Comments

1

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.