I put together in a testpage what’s causing the error. I have 3 pages (includefiles) into one which searches words in the database. It’s not a php error.
It’s just that for some reason $sql doesn’t forget the previous results and on the second page’s code it adds the previous pages results. And on the 3rd page it adds the previous 2 pages’ results.
I have the php file but it links to my db tables which are long. I could probably give you my html file with my php.
I had a bit of a look through the PHP code but I’m struggling to follow where it’s going. I get that you’ve merged three files into one, but I can’t follow where it calls from the first page to the second to the third. Do you mean page in the sense of paginated results, or something else?
No. Loof at the $sql s echoed on the page. The result of the $sql s add from the previous $sql s. Look at the verse numbers how they repeat in the following one.
and then you loop through each result set $result9a and $result9b to build the arrays. However, the PDO doc for query() says : "If you do not fetch all of the data in a result set before issuing your next call to PDO::query(), your call may fail. " which I read as suggesting that once you’ve run a query you need to get the results and work with them, not run another query.
It should be quite straightforward to move the second query to execute after you’ve handled the results for the first one, to see if it helps.
Step by step until you find the problem, same as everyone else does.
You do also seem to go through the same loop more than once, building the arrays each time. If you look at the two queries I mentioned above which are on lines 624 and 625 in the php code, they build up arrays ending in 9a and 9b (and some others) in the following piece of code. Then in 768 and 769, having built another two queries, you then run them and add the results to the same array names. Then again in 920/921, and add the results to the same arrays. I can’t see anywhere that you’ve emptied those arrays between execution.
I know you’ve merged separate files into one, but if you’re only including them and the separate loops are not surrounded by if()s and really execute in the sequence of the overview, I can’t see how the second and third queries would do anything other than append to the same arrays.