Error: Call to undefined function mysql_connect()

I had apache, php, MySQL installed on my PC when the OS was Windows XP.

At the time, I used wamp to install them.

Recently, my PC was changed out for new PC with Windows 7, 64bit machine.

For the past 2 days how, I have had little success trying to reinstall apache, php and MySQL.

Initially, I tried using WAMP but after several unsuccessful attempt to fix missing dll issue, I tried using xamp.

That too was giving me same error.

So, I decided to do it manually.

First, I successfully installed apache.

Then I successfully installed php (tested with phpinfo to confirm).

Finally, I successfully installed MySQL.

I was able to recreate the database and tables I had before switching off PC.

The issue now is running my php app that used to work.

I just keep getting the error:

Call to undefined function mysql_connect() ...

I am also asking to be held by hand to point out what I am doing wrong.

I have been looking at the entries with phpinfo but I can't see what stands out.

Any assistance is greatly appreciated.
LVL 29
Who is Participating?
sammySeltzerConnect With a Mentor Author Commented:
Well, I said yesterday that if I didn't get  a usable answer, I would uninstall everything and start all over.

I did that last night, tried the wamp install again and for some reason, this time, it worked, YEA!

So, I am deleting with a different issue. So, I will close this now.
John EastonDirectorCommented:
I believe the MySQL extension has been depreciated and replaced with mysqli.  A new version of PHP may therefore not support the old extension.

Try changing mysql_connect() to mysqli_connect() and see if that stop the error on that line.  If it does you either need to revert back to an older PHP version, or update all calls to the old extension.
sammySeltzerAuthor Commented:
Thanks for that information.

I didn't know that. I am a .net developer for the most part.

In any case, after making that change, still got same error except that now, it says Call to undefined function mysqli_connect(...)
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

the fact that both wamp and xamp had issues and you are also having issues with a manually instaled version suggest that the problem is related to the change of operating systems and setting appropriate for XP are not valid for 7. you might want to look at the .ini files for wamp which documents what a lot of the settings need to be.  Also look at where you have things located and how you have virtual hosts defined.

There might also be an issue if you are running a mix of 64-bit and 32-bit.

Basically the error indicates the PHP is not interfacing with mysql if you get the error with mysql-_connect(), then that is definitely the case.

sammySeltzerAuthor Commented:
Ok, back to wamp and xamp, I couldnot even complete the installation.

The specific error I was getting with wamp or xamp is that I was missing misvcr100.dll.

I don't believe the issues are related.
I think you mean msvcr100.dll which is part if the Visual C crud that Microsoft pushes out to do internal interfacing:

You can get a free download at:

I had the same problem when a upgraded to the lastest wamp version to support PHP 5

sammySeltzerAuthor Commented:
Sorry about the misspelling but I actually meant this:

Notice 110, 100.

When I downloaded dll from the same link you provided, I started getting a different error.

When I researched that error, the error suggests that the dll was either corrupt or conflicted with OS bit (64 or 32).

It didn't matter what solution I tried, it didn't work for me.

Anyway, as stated, right now, I have done the installations manually.

I just think there is some misconfiguration somewhere.

If I don't get any useful help today or can't google any helpful info, I will have to uninstall everything and start all over again.
AntyraelICT SpecialistCommented:
The error probably indicates that the required MySQLi extension is not loaded.
You should check the php logfile, it should be located under your php installation\logs directory.
Check your php.ini file (you can use phpinfo() to find the inifile being used) and make sure the path to your extensions is correct (Ie. extension_dir = "C:\php\ext").
Also verify the presence of a line "extension=php_mysqli.dll" in that same php.ini file.
Check if the required extension exists (php_mysqli.dll).

When all these settings are correct and the file php_mysqli.dll exists, you can verify that is loaded by checking the phpinfo() page, there should be a configuration header named mysqli.
sammySeltzerAuthor Commented:
Hi, Antyrael,

Maybe, we are getting somewhere here.

I don't see a configuration header that says mysqli.

I  see mysqlnd

Also, extension_dir points to C:\php, not C:\php\ext even though my ini file has the extension pointing to C:\php\ext
AntyraelICT SpecialistCommented:
Hi SammySeltzer,

Did you make any changes to your php.ini file? If so, you will need to restart Apache in order for these changes to be processed.
Is the setting "extension_dir" in your php.ini file commented out perhaps? Or is there another "extension_dir" defined in the inifile?
sammySeltzerAuthor Commented:
I did restart Apache but phpinfo still says c:\php

Here are the files:

; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"
; On windows:
 extension_dir = "c:\php\ext"

Initially, I commented out this line:
extension_dir = "./"

but then I uncommented it in my confusion.

Should it remain commented out?
AntyraelICT SpecialistCommented:
You should only have one active line, so yes, you should comment it out again, then restart Apache.
Is the line with "extension=php_mysqli.dll" also uncommented?
If yes, is there a file php_mysqli.dll in your ext folder?

If it's not set already, you should uncomment the "error_log" setting and provide a path for a logfile (ie. C:\php\Logs\error.log), if php is unable to load the mysqli extension the logfile will tell you.
AntyraelICT SpecialistCommented:
Sorry, I was unavailable last night, couldn't be helped.
Well, at least you got it working, so that's good.
sammySeltzerAuthor Commented:
Please delete as I was unable to get a resolution to the problem.

I had to uninstall the app from my system and tried a new approach that worked for me.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.