Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Question2Answer query fails on a user with # in their name

+2 votes
asked Jan 3, 2012 in Plugins by Scott

The page is here: http://pokemondb.net/pokebase/user-activity/questions/barry%27s%231fan

It's using my user activity plugin but the query that's there is not in my code so it must be from one of the Q2A functions.

Actually the error seems to occur before it ever gets to the process_request function - if I return from the function immediately the error still happens.

Q2A version: 1.4
commented Jan 4, 2012 by Scott
Also, is there an option to not show SQL errors on the live site?

1 Answer

0 votes
answered Jan 4, 2012 by gidgreen

This appears to be happening on a custom page of yours? If so the problem is that # (as well as $ and ^) have special meaning in queries passed to qa_db_query_sub(...) so you should use parameter substitution rather than concatenation to build the query.

commented Jul 2, 2012 by Đặng Minh Tuấn
I've just read what @gidgreen wrote here http://www.question2answer.org/qa/3442/how-to-resolve-insufficient-parameters-registration and guess:

# is used for number VALUES
$ is used for string VALUES (or NaN VALUES)
^ is used for table name
commented Jul 3, 2012 by Scott
If you have separate questions you ought to ask a separate question instead of a comment. You are correct on # and $. ^ is the table /prefix/, i.e. ^ is replaced with qa_ by default, i.e. ^posts = qa_posts