MySQL not being recognized?

I installed Apache, PHP, and MySQL last summer on my PC for developement work. Apache and PHP are running fine, and it appears that MySQL is running fine (I followed instructions in Kevin Yank’s book, “Build Your Own Database Driven Web Site Using PHP & MySQL”.

But, I decided to try Joomla, and it is not recognizing that I have MySQL support. Then, from another article I read today on MySQL installation, it said to run the phpinfo() and scroll down the page. If you see a section on MySQL, you know it’s installed. Well, I didn’t see anything on MySQL at all in that list.

Apache is installed in C:/Program Files/Apache Software Foundation/Apache 2.2

PHP5 is installed in C:/PHP

MySQL is installed in C:/program Files/MySQL (Version, MySQL Server 5.1)

Any ideas why it’s not being recognized? I can log into MySQL from the MySQL Command Line Client, and “play” (Created the Internet Joke Database)

Thanks in advance.

Bill O

Here is what I have in php.ini (and I just enabled extension=php_dba.dll now, so I don’t know yet if that will make a difference):

; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.

;extension=php_bz2.dll
;extension=php_curl.dll
extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_ifx.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
extension=php_msql.dll
extension=php_mssql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_pdo.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll

I thought that I followed the instructions in Kevin’s book to the letter, but I may have missed or overlooked something.

Otherwise, I’m very happy with the way my server is running on my PC. But I’d like to use some of these other programs (I have a client that I think Joomla would be right for).

Thanks, Dan.

It sounds like you don’t have the MySQL extensions for PHP installed. MySQL is fine and there, but PHP can’t communicate with it because it doesn’t have the code to do so installed. I think there’s a section in the book about installing that?

Did you restart the server after making changes to php.ini

:smiley: I did forget that this morning, but it has been restarted in the past several times, so certainly the changes should have taken effect.

What do you think of the settings? Do they look correct? Is there anything else you can think of?

Thanks for the reply.

By the way, I think Kevin is right about installing manually. I have indeed learned a lot by doing it. I have no doubt that I will ge these programs talking to each other, but I have reviewed everything, and I have not spotted the error. But, I suppose it’s like proofing your own writing. Better to have someone else do it.

When you try to connect to MySQL from PHP, are any errors thrown up?

Not sure what you mean “to connect to MySQL from PHP”. However, I think I’m on the path to solving the problem.

Here is where I’m at:

Dan Grossman suggested that PHP was not properly configured to communicate with MySQL, and I think he’s right.

I had downloaded (previously) phpMyAdmin, and went ahead and extracted the files to Apache2.2/htdocs. Following instructions to get it set up, I typed http://localhost/phpMyAdmin. I got a Error 503. Hmmmm. After much thinking, became suspicious about having Virtual Hosts set up. So, I went to httpd.conf and disabled (commented out) #Include conf/extra/httpd-vhosts.conf, restarted Apache, and then type in the address bar: http://localhost/phpMyAdmin. Bingo. But I got an error (phpMyAdmin - ErrorCannot load mysql extension. Please check your PHP configuration. - Documentation), which basically tells me what Dan had said. But, at least it opened the program.

So, now I have to firgure out how to get them talking (I’ve verified the extensions are enabled, and put the libmysql.dll in the Windows path, restarted everything (including my computer), but still get the error.

That’s where I am right now.

Is it possible to have Virtual Hosts enabled and have phpMyAdmin? Must be, but I’m not sure how to solve that one yet (I was getting the Error 503 when typing http://localhost/phpMyAdmin with Virtual Hosts enabled).

Thanks for the help. Sooner or later, I’ll get it. I’m learning a lot along the way.

Regards,
Bill O.

While perusing other forums and thinking of Kevin Yanks book, the lightbulb suddenly went on as to what you meant! Duh! You mean with a PHP script to connect. I have not tried that (at this point, I’m not sure I know how).

I’ve tried a few things today that I came across other places. It seems that I’m not the only one that has trouble, since PHP5 needs to be configured manually for MySQL support.

At this particular moment, I’m at a loss. When I run phpinfo.php, nothing comes up about MySQL. They aren’t talking (like a wife and a mother-in-law!)

Both seem to be running. I run php scrips in my websites and they work. I can access MySQL with the command prompt, and it works. “They just aint talkin’ to each other”.

Computers are funny things. When I find the problem, I know it’s going to be a “Duhh” moment. Usually when something doesn’t work for me, it’s either spelling or syntax. Syntax is everthing (and, of course, so is spelling). But, as I said before, I’m learning lots of things along the way that I wouldn’t have otherwise learned (at least not now). I do want to get this resolved, however, so I can move forward.

Replying to my own post :smiley: just to note that I did get the Virtual host thing solved, and my hunch was right: I set up “localhost” as a “Virtual host”. Found that by searching Google on the issues I’m having.

I’m getting closer and closer to getting this licked, and have learned tons of urealated things in the process. It’s only a matter of time.

Yes: “Fatal error: Call to undefined function mysqli_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\MyWebsites\dreammakergraphics\ est.php on line 3” using following script from the SitePoint book:

<?php

$link= mysqli_connect(‘localhost’, ‘root’, ‘flamenco’);
if (!$link) {
$output = ‘Unable to connect to the database server.’;
include ‘output.html.php’;
exit();
}

?>

As noted previously, there is no problem accessing db using MySQL Command Line Client.

This is really getting frustrating. I have Googled for answers, and I see many, many people have trouble getting PHP5 to work with MYSQL. Some have found solutions (which I have tried, including copying libmysql.dll into Windows/System32 — which is not recommended by anyone —); it still does not work.

I have moved a copy of php.ini over to Windows, have moved extension files from C:/PHP/ext into C:PHP. Restarted Apache, restarted my computer. Nothing seems to work

This moring I notice in phpinfo() Session.save_Path shows “no value”, which is odd because I do have it set to, session.save_path = “C:/Windows/Temp” (I changed the backslashes to forward slashes to see if that had an effect — nada!)

There must be an answer out there somewhere.

Configuring PHP in Windows can be a pain. Never have such problems in Linux.

I would simply uninstall apache and mysql, and install WAMP or XAMPP. One click and your whole environment is created for you (apache+mysql+PHP+perl+phpmyadmin). Everything’s put in the right place so you don’t have to figure it out yourself.

Read through this doc, http://www.ricocheting.com/server/ which I’ve had success with.

One thing to note about WAMP/XAMPP installs (unless things have changed), you’ll be able to connect to mysql fine. The thing is they use ROOT as the user and no password.

This is how mysql installs by default. if you create another account and assign it a password you still have to go in and change the file phpmyadmin points to in order to get it to work.

I have used both in the past. Found installing them separately and following the link I provided gave more understanding of how the pieces worked together.

Well, this is what SitePoint (Kevin Yank) recommends in his book, which is why I chose to go that route. I have indeed learned a lot, and I’m not having a problem with PHP or Apache. It’s MySQL that is the problem (and by extension, phpMyAdmin).

Since there is no urgency in my getting this working on my PC, I may still try to solve it. Other people have. It seems that everyone finds a different solution, probably because of different errors in their particular configuration.

I really hate to undo everything and re-install. I’m always afraid that when I’m done, nothing will work.

I have been just trying to go back through with a fine tooth comb and make sure everthing matches up properly.

One thing I’m not clear about: When to use the backslash and when to use the forward slash. I thought that Kevin Yank had said to always use forward slashes. Then somewhere I saw (don’t remember where) and example that showed the backslash being used. One person reported that when he corrected his .ini files to use the forward slash, his problem was solved. Any thoughts? What is the proper rule?

Bill

Point well taken, and I may end up doing that, though I don’t want to (it’s become a challenge :D). But you’re right; everyone everyplace has said it is a pain.

I really think my problem is that there is one, maybe two things that I have done (file location, or something) that it doesn’t like.

I did notice that phpinfo() showed extension_dir C:\php5, when I had PHP installed in C:\PHP (I had changed this at one point to simply C:\PHP). So, I’m tring to go through and clean up such things, as I strongly suspect this is my problem. I renamed that directory C:\PHP5, and changed it everywhere else.

Also, I have two php.ini files, one in C:\WINDOWS, and one in C:\PHP5, so there may have been some conflict. I had read that it should not be in C:\WINDOWS, then a number of threads said that when they put it there, it solved their problem. There is a lot of confusion out there. I know I need to have it one place or the other, not both.

Since there is really no urgency in me getting this solved, I’m going to keep playing with it for a while. If I get it working, the educational value to me will have been worth it.

Thanks for your reply.

Bill

More on this:

Some research, reading many blogs and forums on this problem reveals that the real problem is that PHP is not loading the php.ini file (and therefore, no extensions).

A look at phpinfo() confirms, no php.ini file loaded. It seems PHP does not care. If it can’t find it, it shrugs and uses all the defaults.

Now the problem is, why can’t it find my php.ini file?

I have tried everyting to no avail. One person posted that when he reinstalled php, his problem went away … till he made some changes to the .ini file and then the problem appeared once again.

This really is frustrating, and installing WAMP is not the solution either, as some of these people had done that.

Bill O.

In phpinfo() what values do you have for Configuration File (php.ini) Path and Loaded Configuration File ?

Configuration File (php.ini) Path: C:\WINDOWS

Loaded Configuration File: (None)

This is what evreyone with this problem is reporting. Further, I find out that (this in the installation documentation) C:\Windows is the default directory where PHP looks for the php.ini file. However most agree that it is not wise to place the file in the Windows directory, but to leave it in the PHP direcory and put the PHP directoy in the PATH via enviromental variables.

Secondly, the Directive in the httpd.conf file

PHPIniDir “c:/php5/”

is supposed to point PHP to look for the file there. That is it’s purpose.

It is now my conclusion, and that of others, that this problem is a PHP bug.

Evidence of this is that some have reported that after struggling with this for a long time, things have mysteriously started working, and they don’t know why.

I have also read on other forums, that installing WAMP makes no difference. Many have reported this problem with that installation as well, and also on iMac installations.

I should also point out that there is nothing wrong with the instructions in Kevin Yank’s book. They are right from the PHP installation guide bundled with the software.

Summary: PHP is not loading the custom php.ini file, which means that it loads none of the extensions you have set, and therefore, neither Joomla, phpMyAdmin, nor any other program that requires PHP and MySQL to communicate, will run.

So way back, many posts ago, I provided a link that will walk you through, step-by-step, setting up php, apache, mysql and then how to configure php to work with mysql correctly.

Did you follow the link and try everything?

Yes, I did. Those are the exact same instructions that I have found everywhere, and are also shipped with PHP.

However, as explained above, the php.ini file does not load. Moreover, this is a problem that is cropping up no matter what your platform.

I’m reading another thread today http://wiki.cementhorizon.com/display/CH/Solution+-+Unable+to+load+dynamic+library+C+php+ext+php_mysql.dll+-+the+specified+module+could+not+be+found

which is saying that some of these extensions must be loaded first before they will work.

In the Apache folder on the server there should be a folder called “bin” try copying php.ini into that (the bin) folder then restart the server.