1

I have the following line:

$reset = "UPDATE pidgeon SET obt='" . $hour . "' WHERE tag='" . $tag . "'";

Which updates just fine. However I need to update an additional row (kill) and I keep getting syntax errors. I've tried the following:

$reset = "UPDATE pidgeon SET obt='" . $hour . "', kill='1' WHERE tag='" . $tag . "'";

$reset = "UPDATE pidgeon SET kill='1', obt='" . $hour . "' WHERE tag='" . $tag . "'";

$reset = "UPDATE pidgeon SET obt='" . $hour . "', kill='" . $num . "' WHERE tag='" . $tag . "'";

I've even done 2 separate UPDATE queries and I get the same syntax error message. I've narrowed it down to the system having issue with the kill row but I'm not sure what's the issue. I've tried setting kill as INT, SMALLINT, BOOL, even CHAR and trying to use 't/f' as values for it. I still get a syntax error. Any suggestions?

2

2 Answers 2

1

KILL is a reserved keyword, so you'll have to enclose it in backticks, like so:

$reset = sprintf("UPDATE pidgeon SET `kill`='1', obt='%s' 
WHERE tag='%s'", $hour, $tag);
Sign up to request clarification or add additional context in comments.

2 Comments

@AlexP: Absolutely. It's always better to use a more descriptive column name.
You are the best! Thank you so much! Its always the silliest errors.
0

Kill is actually a syntax, you can't use them directly.

Just replace kill with another name.

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.