php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45338 Installer generates invalid php.ini
Submitted: 2008-06-23 17:54 UTC Modified: 2008-09-12 16:18 UTC
Votes:18
Avg. Score:4.9 ± 0.5
Reproduced:18 of 18 (100.0%)
Same Version:16 (88.9%)
Same OS:12 (66.7%)
From: tpeterson at americaschoice dot org Assigned: jmertic (profile)
Status: Closed Package: Windows Installer
PHP Version: 5.2.6 OS: Windows NT
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tpeterson at americaschoice dot org
New email:
PHP Version: OS:

 

 [2008-06-23 17:54 UTC] tpeterson at americaschoice dot org
Description:
------------
I have installed Apache 2.2.9, PHP 5.2.6, and MySQL 5.0 on Windows. PHP and Apache work. PHP and MySQL do not. But, MySQL does work on its own. 

I used the PHP installer for php.net downloads page. 

I keep getting the Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\processex.php on line 15 error when I try to connect to my MySQL database from a PHP script.

I did the following:
1) Installed Apache, PHP, and MySQL
2) Ensured that I can run a PHP with built-in functions and display it in my browser with Apache serving it up.
3) Log into MySQL and create a database.
4) Located the extensions path my php.ini file and ensured that my .dlls were in it
5) Located the mysql extension statements in the php.ini file and uncommented them (removed the semicolon before each of them EVEN THOUGH THE MYSQL ONES WERE ALREADY UNCOMMENTED IN THIS DOWNLOAD ALTHOUGH YOU SAY THERE IS NOT BUILT IN SUPPORT).
6) Ensured that both PHP and MySQL have entries in the System Path. 
7) Restarted the server
8) Restarted my computer. 

I got the same error. I looked at the phpinfo() and used get_loaded_extensions() function output but saw that mysql is not installed.

Then I did what the documentation in several places on the internet said to do:
I deleted all the libmysql.dll and php_mysql.dll files except the ones in the php directory and then copied them to the windows/system32 directory and restarted my computer. I still get the same error message. Still do not see mysql installed with the phpinfo() or get_loaded_extensions(). 

I then did the following, which is what another user suggested:
Download the PHP zip distribution and copy the .dlls out of that into my php directory that the installer installed. No luck. I still get the same error message.Still do not see mysql installed with the phpinfo() or get_loaded_extensions(). 

I also tried to load php_mysql.dll with the dl() function but no luck as I am using a multi-threaded server. 

Someone on the internet said to try deleting the php_mysql.dll and libmysql.dll and using the ones from MySQL. I just checked and mysql is only offering mysqli and a replacement for libmysql which I do not want to get into just yet. 

I can get this installed (WAMP) and working if I use, for example, xampp. So this tells me there is something wrong with your PHP code/documentation. 

I am not the only one who has tried. I was teaching a class and all the students tried individually at school and at home with no luck. I tried this on my Windows XP and Windows NT laptops. Nothing. 


Reproduce code:
---------------
// we connect to example.com and port 3307
$link = mysql_connect('localhost', 'root', 'password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

Expected result:
----------------
That I get "Connected successfully" and that the MySQL PHP module shows up in the phpinfo() page. 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-29 11:13 UTC] simonclur at gmail dot com
PHP v5.2.6 requires to the php_mysql.dll (v5.2.6) dll to connect to MySql. 

It appears the PHP v5.2.6 .msi installation package apparently does not copy the new php_mysql.dll into the ./ext directory as it is supposed to.

Download the .zip version of php v5.2.6 and copy the php_mysql.dll file from the zip archive to your /php/ext folder and make sure the following line in your php.ini file is uncommented.

extension=php_mysql.dll

If you're having problems with "Unable to initialize module" for php_mysql.dll then you have copied an incorrect version from a previous or later release of php.

The php_mysql.dll file properties should show the following version information for the dll:
File version: 5.2.6
Created: 11 January 2006 18h15
 [2008-06-29 15:01 UTC] tpeterson at americaschoice dot org
Yes, I know. The file is there, as I said in my write-up. It still won't work.
 [2008-07-02 11:43 UTC] jani@php.net
It just means that PHP is actually using different (old?) php.ini file than the one you're editing. Check from phpinfo() output what the actual _loaded_ php.ini file is.
 [2008-07-03 19:53 UTC] tpeterson at americaschoice dot org
I searched for all old mysql .dll files as the documentation said and for all .ini files. I deleted any old ones. I restarted--the computer and the server. I did this sooooo many times. I was as thorough with this as possible. Also, during the class that I taught, this was the first install as this was the first PHP class. It wasn't just me and my laptop. I also used a work laptop. It was all the students in that class. Even students who did this at home with your installer, after the class was over, couldn't get it to work. So this is not an old ini issue. The ini that was used was the one that your installer set up. And as I said the ini that your installer installed on the systems had everything uncommented. If MySQL, for instance, is not supported why was everything, including the MySQL extension uncommented upon a base install? First install? Anyway, I already thought of this and verified the ini used was the one that I was edited. 

I will find yet another clean laptop and install the WAMP stack on it with this installer and see if there is still an issue.
 [2008-07-12 17:10 UTC] swilliams at csc dot edu
Make sure that you have set your path environment variable to include your php and php extensions directory.  I ran into the same problem, and after I adjusted my path variable, I restarted my computer and everything worked fine.  Hope this helps.
 [2008-07-14 13:26 UTC] tpeterson at americaschoice dot org
Thanks, SWilliams, for the comment. I did do that. I checked the path and rechecked it . . . actually I double and triple checked everything. My students also did so many installs/uninstalls/checks that on the evaluation they suggested it be installed for the next class before the class begins (which I will do and just distribute a hand out on how to set up their own environments at home or work).  I will in the next few weeks install this on a brand new machine that has never had anything installed on it, including but not limited to PHP, MySQL, and Apache, and see what results I get.
 [2008-07-31 19:15 UTC] tpeterson at americaschoice dot org
OK. I found a blank WIndows XP box. Installed Apache and then PHP (your installer). This time I could not get PHP to work. I tried everything. Even the Apache syntax was ok. So I got the PHP.ini file from another machine where the WAMP worked and overwrote the new install's php.ini file. Restarted PHP and PHP worked. I have not had time to set up MySQL. But there is definitely something wrong with the installer for the latest PHP build. Also, I noted that all the exentions were once again uncommented in the php.ini file. No one should/would have all those extensions turned on, at least for security reasons. Also, the problem with the MySQL was because you said you no longer supported it and it had to be uncommented out. So why does the installer install it pre-uncommented? There is something whack about that build.
 [2008-08-11 15:56 UTC] abdullah dot a at gmail dot com
Copy php.ini from the new installation to C:\WINDOWS and overwrite the php.ini present there.
 [2008-09-12 16:18 UTC] jmertic@php.net
I am unable to reproduce this with your steps; installing PHP with the mysql extension works correctly for me.

My only guess is that somehow another version of the libmysql.dll file was being used somehow by PHP. This will be corrected in 5.3+ since mysqli will no longer depend on that dll.

Also, I recommend that you keep the suggested install, and only enable the items you need.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Jul 07 04:03:36 2022 UTC