Install PHP 5.3.1 ...Build Your Own Data Base Driven Site, 4th Edition

Sorry to bother again so soon, but thanks for reading this…

MySQL, Apache and PHP 5.2 all were working perfectly, until I reached p.142, had errors deleting items from database, and realized I had to upgrade to PHP 5.3. I’ve been in a mess since.

After installing VC6 Thread Safe version of PHP 5.3, my apache server is working with the new 5.3, but now I cannot connect to my database. I receive the following error:

Fatal error: Call to undefined function mysqli_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

I have checked my php.ini file a dozen times and am as sure as I can be it’s correct. I have checked everything I can think of, and short of having a missing file in the PHP download, I can’t imagine what happened.

just a note, I now use Notepad++ as my text editor.

I’m very new at this, I hope the solution might be obvious to someone ?? Thanks so much in advance for any help…


Do you have the mysqli extension for PHP installed, and the line in your php.ini?

Hi Dan, thanks so much.

I already had the line extension=php_mysqli.dll uncommented, is that correct ?

The other line you mentioned I hadn’t looked at. Is that file so extension loads automatically ? from the php.ini file:

; If you wish to have an extension loaded automatically, use the following
; syntax:
; extension=modulename.extension
; For example, on Windows:
; extension=msql.dll
; … or under UNIX:

Is that the right section ? If so, should I just remove the semicolon before ? Thanks again… Dennis

It doesn’t matter where you put things in the file

But it’s the mysqli extension you’re trying to enable, not msql

the extension=php_mysqli.dll is not in my php.ini file…! hmm, have you found my problem?

to be sure I just checked the original downloaded file ( php.ini-development ) and it’s definitely not there either. What should I do Dan ??

Add the line, restart apache, and see if it works. Editing the php.ini file isn’t going to hurt anything, you can always remove the line if it’s not right.

I added the line, restarted server, and still no luck…

Dan thank you SO much for your time and what you taught me. Just for others with this problem, this is the solution:

On Windows Vista or above, an entry in the Windows/System32/drivers/etc/hosts file causes mysql_connect() connections to “localhost” to timeout and never connect.

This happens on php 5.3 and above since it now uses mysql native driver which has changed it’s connection behavior compared to libmysql.dll in previous versions. It is not a PHP bug, but definitely a configuration issue for
users on new windows systems.

To get around this, you must remove the entry like this:
::1 localhost

and make sure you still have: localhost

Also, you could change the code to connect to the ip instead, but that is inconvenient if you have many web sites.

This issue occurs on Windows Vista, Windows 7 and Windows Server 2008.