I have a foreach loop that forks within it. After the process forks, it accesses the database. I get an error:
SQLSTATE[HY000]: General error: 2006 MySQL ser
This helped for me: http://www.electrictoolbox.com/mysql-connection-php-fork/
Especially mysql_connect($server, $username, $password, true);
mysql_connect($server, $username, $password, true);