?
Solved

Error: Call to undefined function mysql_connect()

Posted on 2015-01-13
14
Medium Priority
?
251 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 11

Expert Comment

by:John Easton
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 29

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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 29

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 29

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
 
LVL 29

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 29

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 29

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 29

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

862 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