Apr 29

Messages:

Database error: MySQL server has gone away
Database error: Query execution was interrupted
Database error: Lost connection to MySQL server during query

Error type: error

Symptoms:

The query that is executed on a MySQL database returns this error instead of the expected result.

Cause:

The MySQL server connection has been interrupted – either the TCP connection has timed out or the MySQL server has stopped.

Fix:

Check if the connection between the current server and the MySQL server is active.

Restart MySQL: /etc/init.d/mysql restart

Jun 21

Message:

Fatal error: Allowed memory size of 867300 bytes exhausted (tried to allocate 1280200 bytes) in /home/public_html/index.php on line 135

Error type: fatal error

Symptoms:

Page parsing fails and you receive the message in the output. Usually associated with GD (image manipulation) functions or when you deal with large arrays.

Cause:

You do not have enough memory (RAM) available to run that script. This doesn’t happen too often, but you can receive this error when working with large images or with other memory consuming functions (or just large arrays).

Fix:

Set the memory limit to a larger value using:

ini_set("memory_limit","32M");

In that example it is set to 32MB for that particular script. Be careful how much you allow PHP to use because it can slow your entire server down (and it can even cause it to crash!)

You can also change the global value for memory limit from php.ini (if you have access to it):

memory_limit = 32M

Another method is through .htaccess (again, if you have access to that). Please note that this changes the memory limit for all scripts unless you manually specify otherwise.

php_value memory_limit 32M

Jun 21

Message:

Fatal error: Call to undefined function myfunction() in /www/myproject/index.php on line 1345

Error type: fatal error

Symptoms:

Page parsing fails and you receive that message in the output. If display_errors is set to Off in php.ini you will need to check error logs for the message.

Sample Code:

<?php
$id = $_GET[‘id’];
myfunction($id);
?>

Cause:

You are attempting to call a function which does not exist. If you are trying to call a function that you have defined yourself, then make sure that the script has access to it, or if it is a standard PHP function, check  your spelling  and make sure you have the necessary extensions.

Fix:

Check the file with error indicated in the error output and make sure you didn’t misspell the function name.

If that function is defined in a different file make sure that you include (using include/require) before you call it.