Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
2.8k views
in Q2A Core by
edited by

Since a week ago I suddenly get the following error on sr.midneid.at/qa

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.

Is there ANY possiblity to debug this without access to the apache server log as I am on a shared server without any but basic rights. I really hope there is a way to solve this problem without setting up everything step by step and copying questions out of the database over :(

I already tried to delete all plugins from the plugin folder, it did not change anything so I reverted this.

Edit:Based on pupi1985 and steven2's answers I got the queries, they exceed the 8.000 character length limit for a post so I pasted it to pastebin.

http://pastebin.com/a85Gj2JF

Edit2: With the updated help I get the following query as failing. Please note I replaced the real username with "user". The username was correct but I think it is not a good idea to share that information :)

PHP Question2Answer MySQL query error 1142: INSERT command denied to user 'user'@'localhost' for table 'qa_options' - Query: REPLACE qa_options (title, content) VALUES ('flatbox_author', 'Q2A Market')

Q2A version: 1.7.0
by
What are you getting in your error log??

1 Answer

+2 votes
by
selected by
 
Best answer

It is not a good idea to debug this way (and particularly not in a production environment) but considering you seem to have no access to the error logs then probably this might help.

1. Open file qa-include/qa-db.php

2. Locate this line: https://github.com/q2a/question2answer/blob/9a4ffead73bc07da3a9d980c7875c7a3653b0471/qa-include/qa-db.php#L176

3. Replace it with:

echo 'Question2Answer MySQL query: '.$query;

Awful, but it is still better than nothing :)

Edit: The previous approach would show you all the queries run and, at the end, the one to blame. Considering the one to blame based on your output is a query that seems to be right then I assume your output is not complete for some reason. Then you could follow this approach to output only the failing query with some extra information about it:

0. Undo all previous step changes

1. Open file qa-include/qa-db.php

2. Locate this line: https://github.com/q2a/question2answer/blob/9a4ffead73bc07da3a9d980c7875c7a3653b0471/qa-include/qa-db.php#L94

3. Replace in that line @error_log with echo

That will show you any failing queries.

by
To expand on a great idea, and make it production:

Don't replace that line, but **above** it add:
if ( $_SERVER['REMOTE_ADDR'] == '123.33.33.55' ) echo 'Question2Answer MySQL query: '.$query;

replace 123.33.33.55 with your own ip.  This way, you can make it production, and only your ip will see the error code'
by
Very creative idea. I got the output but it is quite long, so please apologize if this is not helpful. I have added a link to pastebin with the result. If you just have ANY idea or direction you can further point me, I would be very glad.
by
Hi Nox, cannot see the link, please provide.
by
I've updated my answer with a slightly better approach
by
edited by
Thank you very much! Now I got a single failing query (I edited the initial answer above) and It makes much more sense.

@sense Forget about the previous link to pastebin, it was not very helpful anyway, but now I only get the failing query posted above.

Please note that I replaced the real database username with "user" but left everything else unchanged.

Edit2: Based on your help I could find out - that for whatever reason my user lost the privileges of insert. I think I will have to contact the webhoster before I can fix anything here. Interestingly, the same user has still all rights in his second database so there definetly is something broken.

Thank you two very much, I will select your answer as solution as soon as I have got a reply from the provider and was able to verify that.
by
Thank you for your help. The problem was that the database began to exceed the providers limit and therefore they stripped my user the INSERT rights.
...