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 =]
Web Developer Cookbook
Saturday, October 29, 2011
Sunday, June 5, 2011
How to add softlink in linux
command: ln -s <target> <the link>
example: ln -s /var/log /home/someone/log
Remarks:
<the link> should not exist, if <the link> exist, then remove it first.
example: ln -s /var/log /home/someone/log
Remarks:
<the link> should not exist, if <the link> exist, then remove it first.
標籤:
linux,
soft link,
symbolic link
Thursday, November 18, 2010
Solution: You don't have permission to access / on this server
Encounter this problem after you set up virtual host in web server?
It is because the folder permission is not set probably.
Here is an example:
<Virtualhost *:80="">
ServerName testhost.com
DocumentRoot "/home/testhost/www"
DirectoryIndex index.php
<Directory "/home/testhost/www">
AllowOverride All
Allow from All
</Directory>
ErrorLog "logs/testhost-error.log"
CustomLog "logs/testhost-access.log" common
</Virtualhost>
Make sure to set permission 755 for each folder in the document root path
/home <- 755
/home/testhost <-- 755
/home/testhost/www <-- 755
It is because the folder permission is not set probably.
Here is an example:
<Virtualhost *:80="">
ServerName testhost.com
DocumentRoot "/home/testhost/www"
DirectoryIndex index.php
<Directory "/home/testhost/www">
AllowOverride All
Allow from All
</Directory>
ErrorLog "logs/testhost-error.log"
CustomLog "logs/testhost-access.log" common
</Virtualhost>
Make sure to set permission 755 for each folder in the document root path
/home <- 755
/home/testhost <-- 755
/home/testhost/www <-- 755
標籤:
apache,
http,
linux,
permission,
server
Thursday, November 11, 2010
Custom error500 / 400 page in symfony 1.4
Custom 400 page:
In config/settings.yml,
all:
.actions:
error_404_module: error
error_404_action: 404
Then when a page is not found, it will forward to "<your_domain>/error/404".
Custom 500 page:
1. Create "error" folder under "config"
2. create "error.html.php" under "config/error"
In config/settings.yml,
all:
.actions:
error_404_module: error
error_404_action: 404
Then when a page is not found, it will forward to "<your_domain>/error/404".
Custom 500 page:
1. Create "error" folder under "config"
2. create "error.html.php" under "config/error"
標籤:
symfony
Monday, November 1, 2010
Solution: route has some missing mandatory parameters
This time I encountered an error in symfony, I set a new route and got this error.
The route is like this:
new_page:
url: /new/page/:id
param: {module: page, action: new}
requirements:
id: \d+
How to fix?
1. Add a default value.
2. Check if you used any routing functions like url_for2() that missing the input parameter.
The route is like this:
new_page:
url: /new/page/:id
param: {module: page, action: new}
requirements:
id: \d+
How to fix?
1. Add a default value.
new_page:
url: /new/page/:id
param: {module: page, action: new, id: 0}
requirements:
id: \d+
2. Check if you used any routing functions like url_for2() that missing the input parameter.
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)