Webhosting Blog

PHP Script unable to connect MySql

While dealing with this issue it was observed that the problem was caused because of sql.safe_mode parameter in php.ini. Follow following steps to sort the issue.

Go to the home directory of the user.

[root@server~]# cd /home/username/public_html

Locate the php.ini file in the public_html folder. If it is not present you can locate the global php.inifile and copy it under your public_html folder
To sort this issue we will locate the global php configuration file php.ini

[root@server public_html]# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

[root@server public_html]#cp /usr/local/lib/php.ini .

Open the php.ini file. Locate the line

sql.safe_mode = On

If sql.safe_mode is enabled, mysql_connect() and mysql_pconnect() ignore any arguments passed to them.Instead, PHP attempts to connect using the following details:

Change the sql.safe_mode flag to off

sql.safe_mode = Off

Restart httpd service.

[root@server~]# service httpd restart

This should now sort the issue.


One response

  1. Pingback: How to Create a Secure PHP Login Script « Notebook of computer networking / IT tips

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s