Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    58
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Unable to load dynamic library 'C:\php\ext\php_mysql.dll'

    Hi all,

    I have a Windows 7 64-bit machine running Apache 2.2, PHP 5.2 and MySQL 5.5.

    I've been following the steps on this site to get them all working together: http://www.bicubica.com/apache-php-mysql/index.php.

    I get the PHP "It works!" page, and I can also create and query a table in command line SQL.

    The problem is getting PHP and MySQL to work together.

    I have added the following to the php.ini file:

    Code:
    LoadModule php5_module "c:/php/php5apache2_2.dll"
    AddHandler application/x-httpd-php .php
    # configure the path to php.ini
    PHPIniDir "c:/windows"
    
    extension=php_mysql.dll to the php.ini
    
    extension_dir = "C:\php\ext"
    
    session.save_path = "C:\WINDOWS\temp"
    I have also added C:\php and C:\php\ext to my PATH system variable (tried adding it at the beginning AND at the end of the existing value).

    I know I'm editing the correct php.ini file because I tested by changing the register_globals variable, restarting Apache and viewing info.php.

    Here is what my Apache error log says:

    Code:
    [Sat Apr 16 10:39:10 2011] [notice] Parent: Received restart signal -- Restarting the server.
    [Sat Apr 16 10:39:10 2011] [notice] Child 3084: Exit event signaled. Child process is ending.
    PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
    [Sat Apr 16 10:39:11 2011] [notice] Apache/2.2.17 (Win32) PHP/5.2.17 configured -- resuming normal operations
    [Sat Apr 16 10:39:11 2011] [notice] Server built: Oct 18 2010 01:58:12
    [Sat Apr 16 10:39:11 2011] [notice] Parent: Created child process 6612
    PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
    <br />
    <b>Warning</b>:  PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified module could not be found.
     in <b>Unknown</b> on line <b>0</b><br />
    [Sat Apr 16 10:39:11 2011] [notice] Child 6612: Child process is running
    [Sat Apr 16 10:39:11 2011] [notice] Child 6612: Acquired the start mutex.
    [Sat Apr 16 10:39:11 2011] [notice] Child 3084: Released the start mutex
    [Sat Apr 16 10:39:11 2011] [notice] Child 6612: Starting 64 worker threads.
    [Sat Apr 16 10:39:12 2011] [notice] Child 3084: All worker threads have exited.
    [Sat Apr 16 10:39:12 2011] [notice] Child 3084: Child process is exiting
    [Sat Apr 16 10:39:13 2011] [notice] Child 6612: Starting thread to listen on port 8080.
    [Sat Apr 16 10:39:18 2011] [error] [client 127.0.0.1] PHP Fatal error:  Call to undefined function mysql_connect() in C:\\Apache\\htdocs\\mysql_test.php on line 9
    I've read loads of posts, and tried many solutions but I still can't get rid of that error. By the way, here is the page I'm trying to load:

    Code:
    <?php
    
    # Define MySQL Settings
    define("MYSQL_HOST", "localhost");
    define("MYSQL_USER", "root");
    define("MYSQL_PASS", "password");
    define("MYSQL_DB", "test");
    
    $conn = mysql_connect("".MYSQL_HOST."", "".MYSQL_USER."", "".MYSQL_PASS."") or die(mysql_error());
    mysql_select_db("".MYSQL_DB."",$conn) or die(mysql_error());
    
    $sql = "SELECT * FROM test";
    $res = mysql_query($sql);
    
    while ($field = mysql_fetch_array($res))
    {
    $id = $field['id'];
    $name = $field['name'];
    
    echo 'ID: ' . $field['id'] . '<br />';
    echo 'Name: ' . $field['name'] . '<br /><br />';
    }
    
    ?>
    Grateful any help!

    Cheers
    Sean

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Okay, so did you go look in the directory C:\php\ext???

    Is the file php_mysql.dll in that directory????
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    58
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Yes it is!

    Any other ideas?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Permissions, maybe?

    Try making sure that the EVERYONE user has read/write permissions to that file (probably only needs READ, but won't hurt to give both).
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    58
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Still no luck. I found this thread which suggests it's actually another file, libmysql.dll which is causing the problem. But I've tried copying it into C:\Windows\System32, and I've tried editing my paths as I said.

    Really frustrated - it's been 2 days now - anyone have any other suggestions?

    Sean

  • #6
    New Coder
    Join Date
    Jul 2009
    Location
    London, UK
    Posts
    58
    Thanks
    8
    Thanked 0 Times in 0 Posts
    ok got it. If anyone is interested, I had to copy the libmysql.dll file into C:\Windows as well as into C:\Windows\System32.

    I know, I know, I shouldn't copy library files straight into the System32 folder, but Windows wasn't picking it up, even when I put C:\PHP at the beginning of my PATH variable. What am I supposed to do?

    Maybe it's a Windows 7 thing...

  • #7
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 207 Times in 204 Posts
    Doing that is really a bad idea. You should be able to add the directory to the end of the path and have it work. You DID reboot after making that change right? Did you include a ; (semi-colon) after c:\php when you added it to the path?
    Dave .... HostMonster for all of your hosting needs

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Quote Originally Posted by djm0219 View Post
    Doing that is really a bad idea.
    Why? Curiosity as to why you think it hurts anything.

    Though I agree that it should have worked where it was.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 207 Times in 204 Posts
    It's a Windows "system" directory and subject to change/removal/replacement at any time. Though the chances of the latter happening are small an update to MySQL that changes that DLL is likely going to cause the person grief if they don't remember that they put it there. It doesn't hurt anything per se, just likely to be a headache causer down the road.
    Dave .... HostMonster for all of your hosting needs

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Okay, those are the kinds of reasons I wouldn't do it. I thought maybe you meant it was harmful in some way. We are in violent agreement.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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