When you see this error message, you properly do not config your php.ini well and so that it cannot connect to mysql server.
1. Wrong path for the mysql.sock
mysql.sock is the instance of the mysql, so first you have to find where does it place at.
You may find it at "/tmp/mysql.sock" or "/var/mysql/mysql.sock".
Go to your php.ini and make sure the value for "pdo_mysql.default_socket", "mysql.default_socket", "mysqli.default_socket" is the right path.
Then restart your web server and try again. Good Luck =]
Showing posts with label php. Show all posts
Showing posts with label php. Show all posts
Saturday, October 29, 2011
Sunday, October 24, 2010
Solution - "Fatal error: Maximum execution time of 30 seconds exceeded"
There are two methods to solve this problem (Fatal error: Maximum execution time of 30 seconds exceeded).
Method 1:
Step 1 : Open php.ini
Step 2 : Modify the value of "max_execution_time" to a greater value say 600
Step 3: Restart Server
Done.
Method 2 (Recommended):
Add "set_limit_time(600)" in your code, where the input parameter is the max execution time, and 0 means unlimited.
Explanation:
You should be aware of this error message, because it should not take more than 30s to complete a script normally. Sometime, it may because of coding mistakes like (infinity loop in your code).
However, you may really need to execute heavy code in many cases, then I would recommend you to use the method 2 to solve this problem.
Method 1:
Step 1 : Open php.ini
Step 2 : Modify the value of "max_execution_time" to a greater value say 600
Step 3: Restart Server
Done.
Method 2 (Recommended):
Add "set_limit_time(600)" in your code, where the input parameter is the max execution time, and 0 means unlimited.
Explanation:
You should be aware of this error message, because it should not take more than 30s to complete a script normally. Sometime, it may because of coding mistakes like (infinity loop in your code).
However, you may really need to execute heavy code in many cases, then I would recommend you to use the method 2 to solve this problem.
標籤:
php
Sunday, October 10, 2010
PHP Filter - email validation
For PHP5, you can validate email format as below:
For PHP version less than 5.0, you have to use regular expression to validate email format.
For reference:
You can found out more build-in validates at php.net each as URL, IP validation which are very useful.
http://php.net/manual/en/filter.filters.validate.php
$email = 'testemail@xxx.com'; if( filter_var($email, FILTER_VALIDATE_EMAIL) ) echo 'Valid email format!'; else echo 'Invalid email format!';
For PHP version less than 5.0, you have to use regular expression to validate email format.
$email = 'testemail@xxx.com';
if( eregi('^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$', $email) )
echo 'Valid email format!';
else
echo 'Invalid email format!';
For reference:
You can found out more build-in validates at php.net each as URL, IP validation which are very useful.
http://php.net/manual/en/filter.filters.validate.php
標籤:
php,
validation
Subscribe to:
Posts (Atom)