Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
69 views
in Plugins by
edited by

Follow up question to:
I'm trying to fix the q2apro-on-site-notifications plugin


I just cloned the Question2Answer repository to add a few commits I've made locally, and noticed the structure seems newer, but the version says 1.8.5 (it also says it was last updated 15 months ago). So I don't know if this is the current version that's currently being worked on, or not. So I can send my pull requests.

I was using version 1.8.6 and the plugin was working properly, although when I changed for this version, I got the following error with the On-site-notifications plugin: 


A Question2Answer database query failed when generating this page.
A full description of the failure is available in the web server's error log file.


The server's error log says:

PHP Question2Answer MySQL query error HY093: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens - Query: SELECT COUNT(event) FROM qa_eventlog WHERE datetime >= FROM_UNIXTIME(?) AND ((userid = ? AND event LIKE "in_%") OR (event IN ("u_message", "u_wall_post") AND params LIKE "userid=?\\t%")), referer: http://localhost/qa/index.php?qa=login

PHP Question2Answer MySQL query error HY093: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens - Query: SELECT COUNT(event) FROM qa_eventlog WHERE datetime >= FROM_UNIXTIME(?) AND ((userid = ? AND event LIKE "in_%") OR (event IN ("u_message", "u_wall_post") AND params LIKE "userid=?\\t%")), referer: http://localhost/qa/index.php?qa=install

Which is this line: q2apro-onsitenotifications-layer.php#L152 


And I also managed to catch this error:

Fatal error: Uncaught Q2A\Database\Exceptions\SelectSpecException: The number of parameters and placeholders do not match in C:\Program Files\xampp\htdocs\qa\qa-src\Database\DbQueryHelper.php:85 Stack trace: #0 C:\Program Files\xampp\htdocs\qa\qa-src\Database\DbConnection.php(189): Q2A\Database\DbQueryHelper->expandParameters('SELECT COUNT(ev...', Array) #1 C:\Program Files\xampp\htdocs\qa\qa-include\qa-db.php(268): Q2A\Database\DbConnection->query('SELECT COUNT(ev...', Array) #2 C:\Program Files\xampp\htdocs\qa\qa-include\qa-base.php(718) : eval()'d code(159): qa_db_query_sub('SELECT COUNT(ev...', 1631421233, '1', '1') #3 C:\Program Files\xampp\htdocs\qa\qa-include\qa-base.php(718) : eval()'d code(113): qa_layer_4_from_q2apro_onsitenotifications_layer_php->getEventCount(1631421233, '1') #4 C:\Program Files\xampp\htdocs\qa\qa-include\app\page.php(381): qa_layer_4_from_q2apro_onsitenotifications_layer_php->doctype() #5 C:\Program Files\xampp\htdocs\qa\qa-include\qa-page.php(53): qa_output_content(Array) #6 C:\Program Files\xampp\htdocs\qa\qa-include\qa-index.php(188): require('C:\\Program File...') #7 C:\Program Files\xampp\htdocs\qa\index.php(27): require('C:\\Program File...') #8 {main} thrown in C:\Program Files\xampp\htdocs\qa\qa-src\Database\DbQueryHelper.php on line 85


Q2A version: 1.8.5 / 1.8.6 DEV

1 Answer

+1 vote
by

i have not faced with such an error, i am using 1.8.5. 

But i think the error is caused by this part.

params LIKE "userid=#\t%"

Try this one:

$param = 'userid='.$userid.'%';

$eventlogCount = qa_db_read_one_value(qa_db_query_sub(

'SELECT COUNT(event) 

FROM ^eventlog

WHERE datetime >= FROM_UNIXTIME(#) AND ((userid = # AND event LIKE "in_%") OR (event IN ("u_message", "u_wall_post") AND params LIKE $))',

$last_visit,

$userid,

$param

)); 

ago by
It's the DEV branch I cloned. https://github.com/q2a/question2answer/tree/dev
Thank you. I'll try this later and see if it works.
...