I hope someone can help me with this, i am having trouble accessing the SQL databases with PHP scripts. Thing is i can create databases from within cpanel, i can access the database through phpmyadmin and i can write data to the database from within phpmyadmin but i can't get any php script to connect to the database. I have tried several script and none will work. Here are some of the server stats: CentOS 4.6 WHM 11.15.0 Apache 1.3.37 Cpanel 11.18.1 PHP 4.4.7 SQL 4.1.22-standard If anyone has any ideas of something i could try i would really appreciate it.
There could be a number of reasons it's not connecting. Can you try connecting to the DB via the mysql command? The syntax would be: mysql -u <username> -p <database_name> If that works, it means that the database is accepting connections for the above DB via this username. In this case, the issue may be with your scripts. In case the above command fails, check the permission and authentication settings for the database.
It connected without problem like that, but still no luck with scripts. I've tried wordpress and joomla both so i dont see how it could be the scripts themselves?
Hi Digitome. 1. What error message do you see when trying to connect to DB from the script? 2. Did you create MySQL user in cPanel and did you add that user to the database? Or you are trying to connect to the DB from the script with your cPanel username?
Only error message it showed was Unable to Connect to SQL Server. and yeah i did add a user to the database but i tried it both ways with the cpanel username too. However i have since installed Apache 2 and PHP5 and it seems to have fixed my problem.
Next time this happens to someone, change the MySQL user password to something more secure/complicated and that do the trick!
I believe the first compile was missing mysql client. Recompiling php again with mysql would resolve the issue. It's not because of the password thing
Make sure you install mysql-devel to include the mysql headers for php to compile against. Easiest way is /scripts/mysqlup --force && /scripts/easyapache
Please print the debug message on the same line that you connect to mysql using php. it would give you some better idea about the reason for non connectivity. Also issue a mysql flush host in case the host has blocked the ip adress with connecting to db.