Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
3.1k views
in Q2A Core by
edited by
I can no longer "reindex questions and answers". The other functions on the statistics page work, except for this.

What happened, and how can I fix this?


Thanks for your help.


Getting total number of questions and answers...
Reindexed 0 of 46 questions and answers...

Notice: Undefined offset: 0 in /home/answers/public_html/qa-include/qa-app-post-create.php on line 109

Notice: Undefined index: - in /home/answers/public_html/qa-include/qa-app-post-create.php on line 109

Warning: require(/home/answers/public_html/qa-include/qa-install.php) [function.require]: failed to open stream: No such file or directory in /home/answers/public_html/qa-include/qa-index.php on line 183

Fatal error: require() [function.require]: Failed opening required '/home/answers/public_html/qa-include/qa-install.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/answers/public_html/qa-include/qa-index.php on line 183

1 Answer

+2 votes
by
edited by
 
Best answer
Please switch off JavaScript in your browser, then click the reindex button again. A more detailed error should then be shown in red in your browser window, and you can send it to me or edit your question here.
by
Thanks. I re-uploaded, but it is STILL broken now unfortunately. I really need to get this working soon.
by
edited by
Here is the latest error, from when I re-uploaded the install file:


Getting total number of questions and answers...
Reindexed 0 of 48 questions and answers...

Notice: Undefined offset: 0 in /home/answers/public_html/qa-include/qa-app-post-create.php on line 109

Notice: Undefined index: - in /home/answers/public_html/qa-include/qa-app-post-create.php on line 109

Warning: Cannot modify header information - headers already sent by (output started at /home/answers/public_html/qa-include/qa-page-admin-recalc.php:63) in /home/answers/public_html/qa-include/qa-install.php on line 141
Question2Answer query failed:

INSERT INTO qa_contentwords (postid, wordid, count) VALUES (40,19,2),(40,79,2),(40,418,1),(40,419,1),(40,261,1),(40,472,1),(40,36,2),(40,310,1),(40,_utf8 '',1),(40,473,1),(40,474,1),(40,25,1),(40,424,1),(40,425,1)

Error 1452:

Cannot add or update a child row: a foreign key constraint fails (`answers_db/qa_contentwords`, CONSTRAINT `qa_contentwords_ibfk_2` FOREIGN KEY (`wordid`) REFERENCES `qa_words` (`wordid`))



===================================================


I have done a multi-file diff on my qa-includes, there are no changes which could affect this. Something has messed up the database itself or so it seems, can you help me fix my database? I have not done any edits to it via phpmyadmin, so I am in the dark as to why this happened.
by
I'm not exactly sure why this is happening, but I think you can fix it by inserting:

if (!empty($wordtoid[$word]))

at line 108 of qa-app-post-create.php, between:

foreach ($contentcount as $word => $count)

... and ...

$contentwordidcounts[$wordtoid[$word]]=$count;
by
Awesome, it worked!
...