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.