Wednesday, April 22, 2009

Resolving a Fatal error: Call to undefined function mysql_connect() in ubuntu

Install php5-mysql and php5-cgi for fix this error.

Details Steps given below

Symptoms

When the page is loaded in the web browser, you receive the error, Fatal error: Call to undefined function mysql_connect().

Fix

  1. Verify that your installation of PHP has been compiled with mysql support. Create a test web page containing and load it in your browser. Search the page for MySQL. If you don't see it, you need to recompile PHP with MySQL support, or reinstall a PHP package that has it built-in.
  2. Verify that the line to load the extension in php.ini has been uncommented. In Linux, the line is extension=mysql.so and in Windows, the line is extension=php_mysql.dll. Uncomment the line by removing the semi-colon. You might also need to configure the extension_dir variable.
3. For installing php5-mysql

#sudo apt-get install php5-mysql
#sduo apt-get install php5-cgi

4. Then restart the mysql and apache

#sudo /etc/init.d/apache2 restart
#sudo /etc/init.d/mysql restart

1 comment:

Unknown said...

genius man!!! but step 3 should be

3. For installing php5-mysql

#sudo apt-get install php5-mysql
#sudo apt-get install php5-cgi

thanks anyway