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

If you have questions about the platform, click here to ask and please use English.

If you just want to try Q2A, please use the demo, which also grants admin access.

Apr 29: Q2A 1.5.2

Question2Answer query fails on a user with # in their name

+2 votes

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
asked Jan 3 in Plugins by DisgruntledGoat
Also, is there an option to not show SQL errors on the live site?

1 Answer

0 votes

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.

answered Jan 4 by gidgreen
Actually I am using substitution in all my queries (unless I am mistaken - can you take a quick look at the code on https://github.com/svivian/q2a-user-activity-plus and verify?)

HOWEVER, I just tried this in my upgraded 1.5 install on localhost and it appears to work just fine (same exact plugin code). So maybe it was an issue that inadvertently got fixed in Q2A 1.5...
You're quite right - my apologies. This is happening because, before the request gets to your plugin, Q2A first checks for a category which matches the path. This is where the error is occurring - in Q2A's own code, not yours. Anyway as you say this bug has been fixed for Q2A 1.5. If you want a workaround for Q2A 1.4.x, check for a # in qa-page-default.php, and if it's there, skip the bit that is commented "Get list of questions...". Sorry again!