PHP not connecting to MySQL

Support for webhosts that use CentOS
Post Reply
gosteen
Posts: 7
Joined: 2011/09/15 23:06:43
Location: Aiken, South Carolina

PHP not connecting to MySQL

Post by gosteen » 2011/09/16 19:55:33

Hello I'm a total newbie and am trying to get PHP to connect to database. here is my code.

[b]



[/b]

When I run this I get

[b]Error connecting to mysql[/b]


I then read an article that made me believe php-mysql was not installed so I ran
[b]yum install php-mysql[/b]

This gave the following output
[b]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.aol.com
* extras: mirror.singleedge.com
* updates: mirror.singleedge.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.i386 0:5.1.6-27.el5_5.3 set to be updated
--> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-mysql
--> Processing Dependency: php-pdo for package: php-mysql
--> Running transaction check
---> Package php-common.i386 0:5.1.6-27.el5_5.3 set to be updated
---> Package php-pdo.i386 0:5.1.6-27.el5_5.3 set to be updated
--> Processing Conflict: php53-common conflicts php-common
--> Finished Dependency Resolution
php53-common-5.3.3-1.el5_6.1.i386 from installed has depsolving problems
--> php53-common conflicts with php-common
Error: php53-common conflicts with php-common
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

[/b]


Any Help would be greatly apprciated

User avatar
TrevorH
Forum Moderator
Posts: 29160
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

PHP not connecting to MySQL

Post by TrevorH » 2011/09/16 20:38:08

You have php53 packages installed so you'll want to install php53-mysql. Suggest you edit your code to include a call to mysql_error() when you have it die so that you can see what error you're actually getting.Might also want to read the first note on [url=http://php.net/manual/en/function.mysql-connect.php]this page[/url] where it talks about the special meaning of the word 'localhost'.

gosteen
Posts: 7
Joined: 2011/09/15 23:06:43
Location: Aiken, South Carolina

Re: PHP not connecting to MySQL

Post by gosteen » 2011/09/17 03:18:09

Trevor,

This is now working! You are too 8-) cool for school. Thanks!

Post Reply

Return to “CentOS 5 - Webhosting Support”