I'm trying to connect my PHP page to MySQL database, but I'm getting this error :PHP Fatal error: Call to undefined function mysql_connect()
I'm working on Ubuntu 11.10 MySQL 5.5 and PHP 5.3.
I have also installed the apache2 server, and it works fine.
I tried to install the php5-mysql module using the following command:sudo apt-get install php5-mysql
I get this error :
The following packages have unmet dependencies: php5-mysql : Depends: php5-common (= 5.3.6-13ubuntu3.1) but 5.3.6-13ubuntu3.9 is to be installed
E: Unable to correct problems, you have held broken packages. I tried to install php5-common again but nothing was successful.
2 Answers
How do I resolve unmet dependencies after adding a PPA?. The answer here may help. Especially the section about sudo apt-get -u dist-upgrade
php5-mysql : Depends: php5-common (= 5.3.6-13ubuntu3.1). This means that php5-mysql was looking for php5-common (=5.3.6-13ubuntu3.1) but I had php5-common (=5.3.6-13ubuntu3.9) installed. I removed the package php5-common (=5.3.6-13ubuntu3.9) which is when the default php5-common (=5.3.6-13ubuntu3.1) was there. I reinstalled the other packages which got removed when I removed php5-common with the following commandsudo apt-get install php5-clisudo apt-get install php5 libapache2-mod-php5sudo apt-get install php5-mysql
and restarted apache2. Now it works fine.