15 Sep

PHP and Memcached Returning Random Data

This took a long time to track down and only applies in specific circumstances:

  • Your process is forking
  • You are using persistent memcache connections
  • The data you request does not match what you receive, for instance you expect an array and an integer is returned.

The problem is caused by the persistent connection being shared after the process has forked. This is a known issue on database connections which is why you should always stop and restart your database connections after a process forks however this is not a documented ‘feature’ of the memcache connections. Trying to close and reopen the memcache connections doesn’t help either.… Read the rest

12 Sep

Jquery Save to Excel II

Slightly more advanced version of my previous script. This script handles if the table doesn’t have an ID which was a problem previously. It also paves the way for multiple export options including Excel, HTML and PDF – whatever your server can handle.

This code is slightly different to previous code as it will add the export buttons to all tables on the page that do not have a class of ‘noExcel’. Run this script from your jQuery ready() function. A simpler version of this code is available at http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/:

var RandomIDToUse = 1000;
function AddActionsToTable(  )
{
$(" table:not(.noExcel)").each(
Read the rest
12 Sep

PHP Processes Getting Killed

This one took a while to suss out.

Symptoms are:

  • Database connections idle for long periods of time.
  • Processes start and then stop intermittently.
  • Processes report ‘Killed’ when you run them.
  • Running ‘dmesg’ from the command line shows the OMM process was called.

If this is happening to you you need to check your logs to see if the OMM (out of memory manager) is getting called. To check this run ‘dmesg’ from a Unix command line and look for the term ‘OMM’. The OM process kicks in when there is not enough memory to satisfy memory requests (malloc) that the system has already OKed.… Read the rest