2

I need to run this query but I get an error:

UPDATE wp_usermeta 
SET meta_value = "a:1:{s:16:\"client_special\";b:1;}" 
WHERE user_id = "1009";

But I get this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE wp_usermeta SET meta_value = "a:1:{s:16:\"cliente_especial\";b:1;}" W' at line 1

It is ok for me, I escaped the " with \ character.

11
  • What DB platform? What are you running the query in (c# code, vbscript, query editor, something else)? Commented Aug 28, 2017 at 19:20
  • show you query command too Commented Aug 28, 2017 at 19:21
  • I run the query in Sequel Pro in the Query area. Commented Aug 28, 2017 at 19:22
  • Instead of escaping you could try simple quotes. Commented Aug 28, 2017 at 19:22
  • 2
    Either you have non-printing characters at the front of your SQL, or you are trying to execute multiple SQL statements in one driver call (eg, in PHP PDO::query). Commented Aug 28, 2017 at 19:26

1 Answer 1

1

As you discovered, and as my comment alluded, non-printing or hidden characters in your SQL statement can lead to unexpected syntax errors.

When confronted with what appears to be ludicrous messages, I find carefully retyping the statement into a different program helps decide whether it is a hidden character issue or a legitimate syntax issue.

It is the act of careful retyping that sanitizes the statement and rules out the non-printing characters. More than once I've done this and I imagine I will continue to do this for the rest of my career!

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

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.