Sometimes the solutions to what seems to be complex problems are easy and often something completely unrelated.
I woke up to one of my websites not working although I did not touch the code for weeks. First thing that I got was Firefox telling me this :
The page isn’t redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete
After ruling out .htaccess and other problems I came to conclusion that it has something to do with a database querying.
So I went to phpmyadmin and tried to manually run the query. To my surprise I got another problem:
Commands out of sync; you can’t run this command now
Great, so suddenly the nested MySQL command I have been using for years stopped working. If you Google for this you will get tons of sites telling you that MySQL has problem with stored procedures (I’m not even using them), that we need to switch to mysqli or PDO extensions, that we are calling client functions in the wrong order etc. However this did not explain why did my code suddenly stop working despite me not touching anything. Maybe database got too large?
To troubleshoot this I wanted to make a copy of a specific table in question and lo and behold – when I copied it via phpmyadmin I got error saying something like “This table is corrupt so it cant be copied”. I checked the table and there it was – a corrupt table! I ran a repair table command, refreshed a site and voila, it worked!
So as you can see the solution was something completely unrelated to error messages and what most websites suggested it was. That does not mean that most people with this errors have the same problem like I did. But it is a reminder that sometimes we should try a simple solutions like checking if database or table became corrupt before spending few hours into troubleshooting something that is working fine anyway 🙂
.