954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Fatal error: "undefined function mysql_connect()"

All,

I've recently installed Apache version 2.2, MySql version 5.1, and PHP version 5.2.13 and am using Windows as my OS. I've gotten PHP to work on the Apache server, and MySql is working properly on its own. However, when I try to connect to a mysql database, I get this error:

fatal error: "undefined function mysql_connect()"

I've read literally 20 to 30 tech forums about this error. It appears to be a common problem with php versions 5 + because mysql extensions are no longer bundled with php. However, I've tried every fix imaginable and still nothing. Fixes I've tried include:

1. removing the semicolon from the php_mysql extension in the php.ini file
2. adding both c:\php and c:\php\ext\ to my PATH directory (php is my main directory)
3. ensuring that my libmysql.dll is located in the same folder as my php.exe file
4. ensuring that the php_mysql extension is available in my c:\php\ext folder

Despite all of these steps (and many more), I've still had no success. Can someone please help me, I'm about to give up on PHP because of this problem...

Justin81
Newbie Poster
2 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Better you uninstall all the thing and Just installed all in one package XAMPP while installing almost all the things are configured automatically. Just connect the database.

http://www.apachefriends.org/en/xampp.html

Its a free open source and easily configured. After installed check with the browser

http://localhost


This is my suggestion.

rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
 

Plz restart your WAMP server(PHP+Mysql+Apache)
if ur using windows
and If u r using Linux.. restart LAMP server....

elex.shwet
Newbie Poster
2 posts since Jul 2010
Reputation Points: 10
Solved Threads: 1
 

This is caused by PHP not loading the MySQL modules. To fix: make sure the file php_mysql.dll (php_mysql.so on non-windows) is in the ext folder of the PHP install; Make sure that the php.ini file that is loaded tells PHP to include that module and that all settings for it are given. Hope this helps.

rbrt13
Newbie Poster
23 posts since Jul 2009
Reputation Points: 11
Solved Threads: 2
 

Better you uninstall all the thing and Just installed all in one package XAMPP while installing almost all the things are configured automatically. Just connect the database.

http://www.apachefriends.org/en/xampp.html

Its a free open source and easily configured. After installed check with the browser

http://localhost

This is my suggestion.


Thanks for the advice Raja. I installed WAMP 2.1 and everything is working very smoothly. Appreciate the help.

Justin81
Newbie Poster
2 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You