I recently encountered : Error establishing mySQL database connection. Correct user/password? Correct hostname? Database server running? in /public_html/libs/db.php on line 87 error and now there is another error that was showing up in the small social bookmarking site run by a few friends.
Solution for this one is very simple. Find the ‘Cache’ folder and delete it’s content and you’ll have your pligg site up and running fine.
There may be a bug fix in the latest version of pligg. The developers of pligg had a cron done to delete the corrupt files that were created by the script. But that’s not a perfect solution as this problem might kick in even before the cron kicks in and the site will potentially be down till then. You can essentially schedule the cron to get to work every other minute, but doesn’t really sound neat.
Here’s what you need to do for a better solution :
if ( (time() – filemtime($cache_file)) > ($this->cache_timeout*3600) )
and replace it with :
if ( (time() – filemtime($cache_file)) > ($this->cache_timeout*3600) || (filesize($cache_file) > 2000000) )
This piece of code will simply delete the cache file if it’s close to 2MB and recreate it. thus there will be no more server crases and the cron need not be in picture
We initially set up a cron to delete the corrupt files created by the script – but that’s hardly a solution as the site could go down before the cron kicks in, and be down until it does (we had it checking every 5 mins to be safe…but still…)
So here’s a simple, better solution. Here’s hoping the devs will include it in their next update. I just checked the 9.9.5 release and nope, problem still there. So here’s what you need to do: