SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems loading the mysqli extension in my local installation of PHP (with Apache)

    Hi,

    I'm having some problems loading the mysqli extension in my local installation of PHP and am getting the "Fatal error: Call to undefined function mysqli_connect()" error. I've read around a bit on the internet and have tried numerous things. First things first my current set-up is:

    Windows 7 Home Premium SP1 64 bit
    IIS is not disabled - but this is mainly because when I went looking for it I could not find it so suspect Win 7 home premium does not come with it. In spite of this point I'm connecting to Apache through port 8080 as I could not get it working through the default port (80?)
    Apache 2.2.21 (Win 32)
    PHP 5.2.17 (vc6 thread safe version)
    MySQL 5.5.19
    My SQL seems to be running fine as I've been in and run stuff using the command line interface. Also my IDE (JetBrains PhpStorm) has a database connector to allow for control and maintenance of the DB within the IDE. This also connects up just fine and I've run some SQL scripts through the IDE.

    Right then so stuff I've tried (in approximate temporal order) I restated the Apache server after each of these and have also totally re-booted the system at least once:

    I followed all the instructions in Kevin Yank's book: Build Your Own Database Driven Website using PHP & MySQL (4th Edition)

    Check the php.ini file in "C:\PHP"
    I have the right path to the extensions folder "C:\PHP\ext"
    the semi-colon in front of "extension=php_mysqli.dll" is removed
    the semi-colon in front of the similarly titled "extension=php_mysql.dll" above is not removed

    Run <? php phpinfo() ?>
    There is no section for mysqli module.
    There are 8 references to MySQL but in each case they are due to the inclusion of "C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin" in the PATH environment variable.
    Under PHP Core I can see that doc_root = "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs" and that extension_dir = "C:\PHP\ext". These are both the values I set in my PHP.ini file so I'm pretty sure the right one is being used. Also the loaded configuration file at the top confirms the same.

    I added C:\PHP to the PATH environment variable. I can see this in phpinfo() so I know this has worked.

    I heard it might be a versioning issue with libmysql.dll so I copied the version of this file from the MySQL installation (in "C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib") over the version in "C:\PHP". This replaced a 1 meg file with a 4 meg file, which seems like quite a movement.
    I've also tried moving this file up into "C:\PHP\ext", "C:\Windows", "C:\Windows\System32" to no avail. The file is deleted from these locations now.

    I've seen some old posts suggesting you need to get the connector software from MySQL rather than the bundled software with the PHP installation, however these all point to the following page http://dev.mysql.com/downloads/connector/php/,which is now dead. If I go to http://www.mysql.com/downloads/ then I don't see a download option for PHP connector.

    I saw another post http://www.sitepoint.com/forums/show...57#post4721657 that claimed to have fixed this issue by installing PHP 5.3. However when I go to http://windows.php.net/download/ the guidance there was to only use the vc6 versions with apache. Currently the vc6 versions are under PHP 5.2 (the PHP 5.3 versions are both vc9). As you can see above I used the thread safe version, I wasn't totally sure on the difference but on reading around I gathered it shouldn't make too much difference.

    Any other thoughts on what to do (or undo) would be gratefully accepted. I really need to get this set up as it's holding up some development I need to do. I previously had the whole thing up and running on my old laptop but it died and so I'm having to get everything up and running on a new computer.

    Regards,
    James

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,770
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by maccas View Post
    Hi,

    I'm having some problems loading the mysqli extension in my local installation of PHP and am getting the "Fatal error: Call to undefined function mysqli_connect()" error. I've read around a bit on the internet and have tried numerous things. First things first my current set-up is:

    Check the php.ini file in "C:\PHP"
    I have the right path to the extensions folder "C:\PHP\ext"
    the semi-colon in front of "extension=php_mysqli.dll" is removed
    the semi-colon in front of the similarly titled "extension=php_mysql.dll" above is not removed
    My setup has both extension=php_mysql.dll and extension=php_mysqli.dll uncommented. Please try it. mysqli is the "improved" MySQL library but that does not necessarily mean it replaces the mysql library entirely.

    I also have a copy of libmysql.dll in the Apache /bin folder. Make sure you copy that DLL file into your Apache /bin folder. libmysql.dll is in your PHP folder and make sure you leave a copy there as well.

    It's been a few years since I installed PHP locally and when I couldn't get it to work I had to make sure I had a copy of the mysql.dll in the Apache /bin folder. That solved the problem.

    Quote Originally Posted by maccas View Post
    I heard it might be a versioning issue with libmysql.dll so I copied the version of this file from the MySQL installation (in "C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib") over the version in "C:\PHP".
    Don't do that just yet. Please reverse this change you made if you haven't already.

    Quote Originally Posted by maccas View Post
    I've seen some old posts suggesting you need to get the connector software from MySQL rather than the bundled software with the PHP installation,
    Don't do that either. MySQL doesn't make their database work with PHP. PHP makes PHP work with MySQL.

    Quote Originally Posted by maccas View Post
    Any other thoughts on what to do (or undo) would be gratefully accepted.
    1) Restore everything like it should be. Use only PHP's DLL files.
    2) Uncomment both mysql and mysqli lines in php.ini.
    3) Copy libmysql.dll from your PHP folder and paste it into your Apache /bin folder while leaving the original copy in the PHP folder.

    Try that. It worked for me when I had problems. It may or may not work for you.

    Also, be sure that if you IIS installed that it is disabled. You can search for ways to do that. If Windows 7 has the Services panel in Control Panel, it should be easy to find.

  3. #3
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheesedude,

    Thanks for the quick response. The issue is resolved (yay!) so I thought I'd post a quick summary of what happened so others alighting here might get some help.

    1) I had a more thorough look for IIS.

    The stuff I'd found previously told me to look in Services. Type services.msc in the Run... box off the start menu. Apparently the entry to look for is World Wide Publishing service (I'm pretty sure I was looking for I was looking for IIS or Internet Information Services previously) and then stop it. Anyway I had neither option listed when I went back and looked.

    However I then found another page by Microsoft which says that IIS is not installed by default on Windows 7 Home Premium, Basic or Starter but can be switched on in Control Panel -> Programs -> Turn Windows Features on or off (on the left hand side). I went here and IIS was there and unchecked (as expected) so I definitely do not have IIS switched on

    2) Uncommented the “extension=php_mysql.dll” line in php.ini and restarted the apache server. No joy.

    3) Copied back the original libmysql.dll file from the PHP install files and restarted the apache server … and it worked!

    In summary since I previously had the correct original libmysql.dll file in situ the fix that has enabled this to work (from where I was this morning) is to uncomment the “extension=php_mysql.dll” line in php.ini. I did not need to copy any files over to the /bin folder of Apache.

    Therefore the things I have different to Kevin’s book in my now working set-up are:
    • Added “C:\PHP” to the PATH environment variable
    • Additionally uncommented the “extension=php_mysql.dll” line in php.ini



    Hope this helps others facing the same issue.

    James

  4. #4
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Works good for me, and Thanks all

    Quote Originally Posted by maccas View Post
    Cheesedude,

    Thanks for the quick response. The issue is resolved (yay!) so I thought I'd post a quick summary of what happened so others alighting here might get some help.

    1) I had a more thorough look for IIS.

    The stuff I'd found previously told me to look in Services. Type services.msc in the Run... box off the start menu. Apparently the entry to look for is World Wide Publishing service (I'm pretty sure I was looking for I was looking for IIS or Internet Information Services previously) and then stop it. Anyway I had neither option listed when I went back and looked.

    However I then found another page by Microsoft which says that IIS is not installed by default on Windows 7 Home Premium, Basic or Starter but can be switched on in Control Panel -> Programs -> Turn Windows Features on or off (on the left hand side). I went here and IIS was there and unchecked (as expected) so I definitely do not have IIS switched on

    2) Uncommented the “extension=php_mysql.dll” line in php.ini and restarted the apache server. No joy.

    3) Copied back the original libmysql.dll file from the PHP install files and restarted the apache server … and it worked!

    In summary since I previously had the correct original libmysql.dll file in situ the fix that has enabled this to work (from where I was this morning) is to uncomment the “extension=php_mysql.dll” line in php.ini. I did not need to copy any files over to the /bin folder of Apache.

    Therefore the things I have different to Kevin’s book in my now working set-up are:
    • Added “C:\PHP” to the PATH environment variable
    • Additionally uncommented the “extension=php_mysql.dll” line in php.ini



    Hope this helps others facing the same issue.

    James
    First, cheesedude you are great and Maccas you are good in following cheesedude's instructions, and I bet it will help a lot of people. You know I use Apache, MySQL, PHP for almost a year now. I always confused about their configurations. Today, on top of fixing the problem, I learned one thing when cheesedude instruct you not to copy an extension libmysql.dll from MYSQL install folder to Apache/bin folder rather he instruct you to make a copy of that extension from PHP install folder to Apache/bin folder. That makes sense b.c as cheesedude said MYSQL extensions cannot make PHP works, It is the opposite. PHP makes MYSQL to work with PHP. That is why when I made a copy of an extension libmysql.dll from PHP install folder and pasted it to Apache/bin folder all my web connection and phpMyadmin worked great. I stuck for the last 24 hrs, but now everything resolved, and I thank you both!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •