Solved

Error: Call to undefined function mysql_connect()

Posted on 2015-01-13
14
204 Views
Last Modified: 2015-02-05
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.
0
Comment
Question by:sammySeltzer
  • 7
  • 4
  • 2
  • +1
14 Comments
 
LVL 10

Expert Comment

by:JEaston
ID: 40547186
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.
0
 
LVL 28

Author Comment

by:sammySeltzer
ID: 40547236
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(...)
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40547237
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.

Cd&
0
 
LVL 28

Author Comment

by:sammySeltzer
ID: 40547254
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.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40547283
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:

http://www.dll-files.com/dllindex/dll-files.shtml?msvcr100

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

Cd&
0
 
LVL 28

Author Comment

by:sammySeltzer
ID: 40547326
Sorry about the misspelling but I actually meant this:
msvcr110.dll

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.
0
 
LVL 4

Expert Comment

by:Antyrael
ID: 40548406
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.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 28

Author Comment

by:sammySeltzer
ID: 40548854
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
0
 
LVL 4

Expert Comment

by:Antyrael
ID: 40548891
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?
0
 
LVL 28

Author Comment

by:sammySeltzer
ID: 40548907
I did restart Apache but phpinfo still says c:\php

Here are the files:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
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?
0
 
LVL 4

Expert Comment

by:Antyrael
ID: 40550659
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.
0
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 0 total points
ID: 40551744
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.
0
 
LVL 4

Expert Comment

by:Antyrael
ID: 40552109
Sorry, I was unavailable last night, couldn't be helped.
Well, at least you got it working, so that's good.
0
 
LVL 28

Author Closing Comment

by:sammySeltzer
ID: 40590667
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.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now