Environment: My Own PC

I have downloaded the Latest PHP + mySQL + IIS 5.1 in my pc

Gone through everything in install.txt and works ok.

so, the problem occur when i try to launch the index.php

Fatal error: Call to undefined function mysql_connect() in C:\Drupal\drupal-4.6.2\includes\database.mysql.inc on line 31

this msg came out.

whats the major problem????

anyone please?


micha_1977’s picture

thats a PHP Function

seems its missing, see PHP 5 notes for further info

work in progress with Drupal 4.6: langmi.de

cdestiny’s picture

hi micha, thanks for answering my noob question. :) i tried some sample at new php file.

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
   die('Could not connect: ' . mysql_error());
echo 'Connected successfully';

**'localhost' remain 'localhost'
**'mysql_user' replace with my database username
**'mysql_password' replace with my databse password.

the same problem still occur. is that means i need to modify the php.ini ????

micha_1977’s picture

i just guess that - according to my links - you need to "turn on" the mysql for php5

work in progress with Drupal 4.6: langmi.de

cdestiny’s picture

you are right, i check on my phpinfo()
i cant find mySQL listed inside there. I need to configure with php.ini

i am trying to enable it. please tell me if you know how to enable it. thanks buddy!!

loloyd’s picture

I also encountered the same problem and sarched/browsed around for the solution. From others experiences, I gathered that the problem lies in my failure to properly configure php. In php's documentation, they stated that they have disabled mysql support by default.

To fix this, find the line:


from your php.ini file and remove the leading semicolon to uncomment it like so:


You might also want to uncomment the extension to php_gd2.dll (for graphics purposes).

Next, ensure that the files php_mysql.dll and libmysql.dll can be reached by php by modifying and uncommenting the line:

extension_dir = "C:\php\ext\"

to something more appropriate to your system. Verify this by looking at the value returned by:

< ?php phpinfo() ? >

That should now work. The message "Fatal error: Call to undefined function mysql_connect() in C:\...drupal-x.x.x\includes\database.mysql.inc on line 31" simply means that the function mysql_connect was not found by php. Therefore, you only need to configure php to enable its encapsulating library for it to work.

trantt’s picture

I'm still having the same problem, can someone help me to resolve this problem?

I'm using windows xp, apache 2.055, mysql, php 5.1.1...
I modified php.ini (this ini file is located under the apache directory (c:\Progarms Files\Apache Group\Apache2) accordingly to what you mentioned above.... I also modified database.mysql.inc with the following info:

$connection = mysql_connect($url['localhost'], $url['drupal'], $url['drupal'], TRUE) or die(mysql_error());
mysql_select_db(substr($url['path'], 1)) or die('unable to select database');

Please help, I am trying to learn drupal and I got stuck...


btw, i ran phpinfo to verify mysql and it wasn't there

coreyp_1’s picture

if phpinfo isn't showing mysql as installed, then don't bother with drupal yet... your problems lie elsewhere.

you must turn on mysql in your php.ini file, just as the previous post stated. Did you install everything on your own, or did you follow a tutorial, or use another, completely different method (like WAMP5)?

trantt’s picture

I installed everything on my own. I was able to import drupal database to mysql server, and I was also ran php from apache web server... Only one problem left (before starting to learn drupal) is php connection to mysql server:
1. I copied php.ini to apache root folder (C:\Program Files\Apache Group\Apache2)
2. The following changes were made to the php.ini:
1. extension_dir = "C:\Program Files\Apache Group\PhP51\ext\"
2. extension=php_mysql.dll
3. The following changes were made to the httdp.config:
AddHandler server-parsed .shtml
LoadModule php5_module "C:/Program Files/Apache Group/PhP51/php5apache2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/Program Files/Apache Group/PhP51"

DirectoryIndex index.shtml index.php index.php5 index.html index.html.var

NameVirtualHost *:80

I have been searching for an answer for the past two days but haven't found an answer yet.


coreyp_1’s picture

not sure if it matters, but I had to put php.ini into my C:\Windows directory.

Other than that, I'm out of ideas.

trantt’s picture

I tried this before (copy php.ini to c:\windows and php_mysql.dll and libmysql.dll to c:\windows\System32) and it failed as well. If I'm not wrong, this method is used for IIS server.

coreyp_1’s picture

no, I'm running apache.

It may be odd, but I never claimed to be normal in the first place...


dmeikle’s picture

after placing the php.ini file in c:\winnt I uncommented the

then i RESTARTED IIS in the services (not by right click->restart IIS in the ISS manager).

this gave me an error of './ext' not found - I knew i was finally onto something !

I then uncommented:

restarted IIS in the services again, and voila! it worked.
thanks for all the good hints and tips in the above threads. they worked for me.

mgdoyle’s picture

Make sure that the php.ini is only in C:\Windows and not in your php root directory where the php.exe file is. You can leave it as php-dist.ini and rename it only in the c:\windows directory.

Hope that helps.

liquidf’s picture

The last thing that was missing for me was the following:

Both libmysql.dll and php_mysql.dll have to be in the C:\WINDOWS\system32 folder.
Additionally, php.ini must be in C:\WINDOWS\ as others have stated.

georgesteban22’s picture


I had the same problem with PHP, MySql and Apache.

I finally solved my problem with the following:

1.Search your server for libmysql.dll. Delete any instance of libmysql.dll that is not in the C:\PHP directory. This limits the possibility of older MySQL client API's being used with PHP.

2.Search your server for php_mysql.dll. Delete any instance of php_mysql.dll that is not in the C:\PHP directory. This limits the possibility of older MySQL client API's being used with PHP.

3.Open your C:\%WIN%\php.ini file in a text editor (Notepad will work).

Search for the line that looks like --> ;extension=php_mysql.dll

Change this line to --> extension=php_mysql.dll

Uncomment: extension_dir="c:\php\ext"

Save the modified php.ini file.

4. Copy php.ini to C:\%WIN%\System32

5. Copy C:\PHP\libmysql.dll and C:\PHP\ext\php_mysql.dll to the C:\%WIN%\system32 folder.

Restart Apache/IIS and test it out.

It worked for me

aviralmsharma’s picture

Man... you are a genius... you are simply amazing... i cannot stop praising you... :D God Bless you :)

ricem84’s picture

I’m getting a similar error message. I tried the things mentioned, and it hasn’t worked yet.

I’m a little clueless.

In C:\%WIN%\System32, is %WIN% a wildcard for whatever path goes from C to System32?

Php.ini is supposed to go in System 32? My browsers could still read php.ini with it in the php folder.

Is having more than one copy of a .dll on the computer a detriment? If the .dll is called upon, does it directly search a certain location?

How do you restart Apache/IIS?

Is an INI-DIST file the same as a .ini file?

Where do libmysql.dll and php_mysql.dll go – the instances you don’t delete? Do they go in the /ext folder or the php folder?

Is there any other way to diagnose my problem if trying what was mentioned to work doesn’t work?


Parabola’s picture

A little googling would go a long way for most of what you are asking. There are tons of tutorials on getting PHP working with IIS. to restart IIS, open the IIS MMC, right click the local computer, goto all tasks, and click Restart IIS.

ricem84’s picture

I found this site by googling. I could either google for a lot more hours or just post on this message board and hope someone answers my newbie questions, which all relate to the php not detecting mysql problem. Sometimes I have trouble finding the answers to things that are background knowledge.

I don't think I'm using IIS, which would explain why I've never heard it before. I'm using Apache and mysql.

Does that mean the solution mentioned isn't right for me? Because I'm using Apache?

ricem84’s picture

georgestaban's technique worked, I think!

so...I was being idiotic when I wrote this post. I forgot to use localhost. No problems.

Dammit. It didn't work. I am at a complete loss about this fatal error error.

ricem84’s picture

Searching on the net, there aren't that many people who have this problem. Can the problem be solved when installing? I don't mind reinstalling. I haven't customized Apache. Is there some option I chose or didn't choose to make things work with mysql?

ricem84’s picture

Okay, I finally got it. I did everything that people suggested and it didn't work until I added a copy of php.ini to c:\php
The main problem I found was that php.ini's address was showing as not present when I looked at phpinfo(); until I moved it somewhere else.

ashok.aruchswamy@gmail.com’s picture

Wowwwwwww......... that's amazing piece of information. You saved lot of my time........... I just followed your steps and it works........ once again you are amazing

sboyce’s picture

Worked! Thanks georgesteban22. I've been fighting with this all week and tried several other "suggestions" from the web but yours was the one that worked. So glad I found your response. I've installed all of this several times in the past and never had a problem. But, I recently got a new computer with all the latest and "greatest" updates and I've had nothing but heartache. You're a gem, thanks again so much for your perserverance figuring this out!

Ashish Gupta’s picture

please send me complete solution that how can i connect php page with mysql database with using IIS server

sushtaurus’s picture

Hello everyone,
Even I was facing with same problem. I read many forums and tried everything, but of no use. Atlast i have renamed 'php.ini' file in the root php directory(the folder in which you installed your php) to just 'php' and it worked for me.

STEPS to modify php:

# I unzipped PHP to:

# Rename php.ini-dist (In my case C:\php\php.ini-dist) to php (just php...dont rename to php.ini)

#Edit your php.ini
Open php.ini in a text editor and scroll down about halfway through the file and look for doc_root then change it to point to whatever your Apache DocumentRoot is set to.
In my case:
doc_root = 'C:\Apache\htdocs'

Scroll down about 7 more lines and change the extension_dir from extension_dir = './' to the location of the ext directory after you unzipped PHP.
In my case:
extension_dir = 'C:\php\ext'

search for
and remove the
infont of that line

#Copy libmysql.dll file from your php folder to 'C:\Windows\System32'

#Editing Apache Conf File
In my case 'C:\Apache\conf\httpd' with notepad.
At the end of the file add the below code without any quotations and all.
LoadModule php5_module 'C:/php/php5apache2_2.dll'
AddType application/x-httpd-php .php
PHPIniDir 'C:/php'

Restart Apache.
create a test.php file in your Apache 'DocumentRoot' folder ('C:\Apache\htdocs' in my case). In your test.php file, type these 3 lines and then load the file in your Internet browser like http://localhost/test.php (you should get a whole long list of php variables, settings, etc):


my_connect command should also work when you install and configure mysql properly.

* This should work for you. Incase it doesnt work
Download connectors for php from mysql website.

Unzip it. You would be getting libmysql.dll file . Copy this file to C:\Windows\System32.
It takes lot of Trial and error. All the best.

my email : sushtaurus@gmail.com