A PHP/MySQL Connnector Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TonyB

    #1

    A PHP/MySQL Connnector Problem

    I'm running the zip'd version of PHP (PHP 5.1.2 zip package) downloaded
    from here: http://www.php.net/downloads.php. PHP won't connect with
    MySQL.
    [color=blue]
    >From docs and threads, it seems enabling PHP/MySQL connectivity on a[/color]
    Windows XP machine requires three configuration edits. These are:

    1. In php.ini, enable php_mysql.dll by uncommenting
    "extension=php_ mysql.dll".
    2. In php.ini, set "extension_ dir" to the folder containing
    php_mysql.dll which on my PC is C:/core/web/php512/ext/
    3. Windows system PATH. Add ";\%SystemRoot% \core\web\php51 2" which
    places libmysql.dll on the PATH.

    On my workstation, Apache and PHP are installed in the following
    directorys:

    C:\Program Files\Apache Group\Apache2
    C:\Program Files\Apache Group\Apache2\c onf
    C:\Program Files\Apache Group\Apache2\c onf\httpd.conf

    C:\core\web\php 512
    C:\core\web\php 512\php.ini
    C:\core\web\php 512\libmysql.dl l
    C:\core\web\php 512\ext
    C:\core\web\php 512\ext/php_mysql.dll
    C:\core\web\Apa che2\htdocs
    C:\core\web\Apa che2\htdocs\hel lo.php

    PHP was put into C:\core\web\php 512 in order that phpMyAdmin could be
    installed somewhere other than C:\Program Files\Apache
    Group\Apache2\h tdocs.

    http.conf has the following four changes:

    LoadModule php5_module "c:\core\web\ph p512\php5apache 2.dll"
    AddType application/x-httpd-php .php
    PHPIniDir "C:\core\web\ph p512"
    DocumentRoot "C:/core/web/Apache2/htdocs"

    The workstation is running:
    Windows XP Media Center Edition Service Pack 2
    Apache 2.0.55
    MySQL 5.0.18
    PHP 5.1.2 (zip)

    Apache works fine; MySQL is running; PHP works okay except it just
    won't connect to MySQL.

    As noted above, configuration changes were made as per online docs and
    discussion threads. I set extension_dir to "extension_ dir =
    C:/core/web/php512/ext", uncommented extension=php_m ysql.dll from
    php.ini and added "c:\core\web\ph p512" to my PATH (followed by a PC
    restart). However, the message "Unable to load dynamic library
    'C:/core/web/php512/ext/php_mysql.dll'" continues to appear in the
    apache error log when apache is started. Much tweaking of the
    extension_dir entry has no effect.

    Any thoughts would be greatly appreciated.... .. -Tony

    I'm using the zip download of PHP as noted in an earlier post......

    From: Tony Marston - view profile
    Date: Fri, Dec 24 2004 12:17 am
    Email: "Tony Marston" <t...@NOSPAM.de mon.co.uk>
    Groups: comp.lang.php

    Use the zip download if you want to run PHP as an Apache module as the
    msi
    version is CLI only. Also be aware that the directory structure with
    PHP 5
    is different from PHP 4.

    --
    Tony Marston


    This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




    "Dick Watson" <littlegreenge. ..@mindspring.c om> wrote in message


    news:nCOyd.8782 $9j5.3025@newsr ead3.news.pas.e arthlink.net...

  • David Haynes

    #2
    Re: A PHP/MySQL Connnector Problem

    TonyB wrote:[color=blue]
    > I'm running the zip'd version of PHP (PHP 5.1.2 zip package) downloaded
    > from here: http://www.php.net/downloads.php. PHP won't connect with
    > MySQL.
    >[color=green]
    >>From docs and threads, it seems enabling PHP/MySQL connectivity on a[/color]
    > Windows XP machine requires three configuration edits. These are:
    >
    > 1. In php.ini, enable php_mysql.dll by uncommenting
    > "extension=php_ mysql.dll".
    > 2. In php.ini, set "extension_ dir" to the folder containing
    > php_mysql.dll which on my PC is C:/core/web/php512/ext/
    > 3. Windows system PATH. Add ";\%SystemRoot% \core\web\php51 2" which
    > places libmysql.dll on the PATH.
    >
    > On my workstation, Apache and PHP are installed in the following
    > directorys:
    >
    > C:\Program Files\Apache Group\Apache2
    > C:\Program Files\Apache Group\Apache2\c onf
    > C:\Program Files\Apache Group\Apache2\c onf\httpd.conf
    >
    > C:\core\web\php 512
    > C:\core\web\php 512\php.ini
    > C:\core\web\php 512\libmysql.dl l
    > C:\core\web\php 512\ext
    > C:\core\web\php 512\ext/php_mysql.dll
    > C:\core\web\Apa che2\htdocs
    > C:\core\web\Apa che2\htdocs\hel lo.php
    >
    > PHP was put into C:\core\web\php 512 in order that phpMyAdmin could be
    > installed somewhere other than C:\Program Files\Apache
    > Group\Apache2\h tdocs.
    >
    > http.conf has the following four changes:
    >
    > LoadModule php5_module "c:\core\web\ph p512\php5apache 2.dll"
    > AddType application/x-httpd-php .php
    > PHPIniDir "C:\core\web\ph p512"
    > DocumentRoot "C:/core/web/Apache2/htdocs"
    >
    > The workstation is running:
    > Windows XP Media Center Edition Service Pack 2
    > Apache 2.0.55
    > MySQL 5.0.18
    > PHP 5.1.2 (zip)
    >
    > Apache works fine; MySQL is running; PHP works okay except it just
    > won't connect to MySQL.
    >
    > As noted above, configuration changes were made as per online docs and
    > discussion threads. I set extension_dir to "extension_ dir =
    > C:/core/web/php512/ext", uncommented extension=php_m ysql.dll from
    > php.ini and added "c:\core\web\ph p512" to my PATH (followed by a PC
    > restart). However, the message "Unable to load dynamic library
    > 'C:/core/web/php512/ext/php_mysql.dll'" continues to appear in the
    > apache error log when apache is started. Much tweaking of the
    > extension_dir entry has no effect.
    >
    > Any thoughts would be greatly appreciated.... .. -Tony
    >
    > I'm using the zip download of PHP as noted in an earlier post......
    >
    > From: Tony Marston - view profile
    > Date: Fri, Dec 24 2004 12:17 am
    > Email: "Tony Marston" <t...@NOSPAM.de mon.co.uk>
    > Groups: comp.lang.php
    >
    > Use the zip download if you want to run PHP as an Apache module as the
    > msi
    > version is CLI only. Also be aware that the directory structure with
    > PHP 5
    > is different from PHP 4.
    >
    > --
    > Tony Marston
    >
    >
    > http://www.tonymarston.net
    >
    >
    >
    > "Dick Watson" <littlegreenge. ..@mindspring.c om> wrote in message
    >
    >
    > news:nCOyd.8782 $9j5.3025@newsr ead3.news.pas.e arthlink.net...
    >[/color]
    Did you copy libmysql.dll to apache2/bin?

    -david-

    Comment

    • Jerry Stuckle

      #3
      Re: A PHP/MySQL Connnector Problem

      David Haynes wrote:[color=blue]
      > Did you copy libmysql.dll to apache2/bin?
      >
      > -david-
      >[/color]

      Not necessary if you update the PATH to point to it.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • TonyB

        #4
        Re: A PHP/MySQL Connnector Problem

        It's looking better......... .......

        Copying libmysql.dll to apache2/bin eliminated the "Unable to load
        dynamic library
        'C:/core/web/php512/ext/php_mysql.dll'" message from the Apache
        log...... Now, during a restart of Apache, the log (below) is clean of
        startup error messages. (The error in the last line of the log is
        coming from the application). The server now appears to be locating
        functions in php_mysql.dll.

        [Mon Feb 20 08:25:40 2006] [notice] Child 684: Child process is exiting
        [Mon Feb 20 08:25:40 2006] [notice] Parent: Child process exited
        successfully.
        [Mon Feb 20 08:25:45 2006] [notice] Apache/2.0.55 (Win32) PHP/5.1.2
        configured -- resuming normal operations
        [Mon Feb 20 08:25:45 2006] [notice] Server built: Oct 9 2005 19:16:56
        [Mon Feb 20 08:25:45 2006] [notice] Parent: Created child process 4316
        [Mon Feb 20 08:25:45 2006] [notice] Child 4316: Child process is
        running
        [Mon Feb 20 08:25:45 2006] [notice] Child 4316: Acquired the start
        mutex.
        [Mon Feb 20 08:25:45 2006] [notice] Child 4316: Starting 250 worker
        threads.
        [Mon Feb 20 08:25:53 2006] [error] [client 127.0.0.1] PHP Warning:
        mysql_connect() [<a
        href='function. mysql-connect'>functi on.mysql-connect</a>]: Unknown
        MySQL server host 'mysql' (11001) in
        C:\\core\\web\\ Apache2\\htdocs \\app1\\helloMy SQL.php on line 34

        I don't understand why this is now working when the folder containing
        libmysql.dll was on the path (see the echo output below); but it's
        working so that's good... From a DOS window, echoing the path results
        in the output below; the folder ..\php512 appears to be on the path
        and this is where libmysql.dll was (and is) sitting..

        C:\Documents and Settings\HP_Adm inistrator>echo %PATH%

        C:\WINDOWS\syst em32;C:\WINDOWS ;C:\WINDOWS\Sys tem32\Wbem;c:\P ython22;\C:\WIN DOWS\

        core\web\php512 ;;C:\PROGRA~1\C OMMON~1\MUVEET~ 1\030625;C:\PRO GRA~1\COMMON~1\ MUVEE
        T~1\030625

        So, for my PC, one additional step (step 4) is added to the connector
        setup procedure:.

        1. In php.ini, enable php_mysql.dll by uncommenting
        "extension=php_ mysql.dll".
        2. In php.ini, set "extension_ dir" to the folder containing
        php_mysql.dll which on my PC is C:/core/web/php512/ext/
        3. Windows system PATH. Add ";\%SystemRoot% \core\web\php51 2" which
        places libmysql.dll on the PATH.
        4. Copy php_mysql.dll to ../Apache2/bin.

        Thanks for your suggestion.

        The next step is to figure out why "mysql" is the wrong name for the
        mysql instance on my pc... The php page is bombing here:

        $link = mysql_connect(' mysql', 'root', '<password>')
        or die('Could not connect: ' . mysql_error());

        According to the server information section of MySQL Administrator, the
        network name of the MySQL server is localhost.... lets see if changing
        mysql to localhost has an effect.....


        -Tony

        Comment

        • Jerry Stuckle

          #5
          Re: A PHP/MySQL Connnector Problem

          TonyB wrote:[color=blue]
          > It's looking better......... .......
          >
          > Copying libmysql.dll to apache2/bin eliminated the "Unable to load
          > dynamic library
          > 'C:/core/web/php512/ext/php_mysql.dll'" message from the Apache
          > log...... Now, during a restart of Apache, the log (below) is clean of
          > startup error messages. (The error in the last line of the log is
          > coming from the application). The server now appears to be locating
          > functions in php_mysql.dll.
          >
          > [Mon Feb 20 08:25:40 2006] [notice] Child 684: Child process is exiting
          > [Mon Feb 20 08:25:40 2006] [notice] Parent: Child process exited
          > successfully.
          > [Mon Feb 20 08:25:45 2006] [notice] Apache/2.0.55 (Win32) PHP/5.1.2
          > configured -- resuming normal operations
          > [Mon Feb 20 08:25:45 2006] [notice] Server built: Oct 9 2005 19:16:56
          > [Mon Feb 20 08:25:45 2006] [notice] Parent: Created child process 4316
          > [Mon Feb 20 08:25:45 2006] [notice] Child 4316: Child process is
          > running
          > [Mon Feb 20 08:25:45 2006] [notice] Child 4316: Acquired the start
          > mutex.
          > [Mon Feb 20 08:25:45 2006] [notice] Child 4316: Starting 250 worker
          > threads.
          > [Mon Feb 20 08:25:53 2006] [error] [client 127.0.0.1] PHP Warning:
          > mysql_connect() [<a
          > href='function. mysql-connect'>functi on.mysql-connect</a>]: Unknown
          > MySQL server host 'mysql' (11001) in
          > C:\\core\\web\\ Apache2\\htdocs \\app1\\helloMy SQL.php on line 34
          >
          > I don't understand why this is now working when the folder containing
          > libmysql.dll was on the path (see the echo output below); but it's
          > working so that's good... From a DOS window, echoing the path results
          > in the output below; the folder ..\php512 appears to be on the path
          > and this is where libmysql.dll was (and is) sitting..
          >
          > C:\Documents and Settings\HP_Adm inistrator>echo %PATH%
          >
          > C:\WINDOWS\syst em32;C:\WINDOWS ;C:\WINDOWS\Sys tem32\Wbem;c:\P ython22;\C:\WIN DOWS\
          >
          > core\web\php512 ;;C:\PROGRA~1\C OMMON~1\MUVEET~ 1\030625;C:\PRO GRA~1\COMMON~1\ MUVEE
          > T~1\030625
          >
          > So, for my PC, one additional step (step 4) is added to the connector
          > setup procedure:.
          >
          > 1. In php.ini, enable php_mysql.dll by uncommenting
          > "extension=php_ mysql.dll".
          > 2. In php.ini, set "extension_ dir" to the folder containing
          > php_mysql.dll which on my PC is C:/core/web/php512/ext/
          > 3. Windows system PATH. Add ";\%SystemRoot% \core\web\php51 2" which
          > places libmysql.dll on the PATH.
          > 4. Copy php_mysql.dll to ../Apache2/bin.
          >
          > Thanks for your suggestion.
          >
          > The next step is to figure out why "mysql" is the wrong name for the
          > mysql instance on my pc... The php page is bombing here:
          >
          > $link = mysql_connect(' mysql', 'root', '<password>')
          > or die('Could not connect: ' . mysql_error());
          >
          > According to the server information section of MySQL Administrator, the
          > network name of the MySQL server is localhost.... lets see if changing
          > mysql to localhost has an effect.....
          >
          >
          > -Tony
          >[/color]

          Probably because the first parameter to mysql_connect() is a server
          name, and 'mysql' is not a valid server name.

          If you're connecting to the local machine you should use 'localhost'
          (and 'localhost' should be in your hosts file). Alternatively, this can
          be an ip address - 127.0.0.1 for the localhost.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • TonyB

            #6
            Re: A PHP/MySQL Connnector Problem

            Yes... That worked.... Using "localhost" did the trick. Now, the
            little php test page returns results from mysql. And, even better,
            phpMyAdmin ver 2.7 began working once config.inc.php was created and
            updated with the right id and password. More checkout is needed, but
            phpMyAdmin can now create DBs and browse tables. Things are looking
            good.

            Thanks for your help.
            -Tony

            Comment

            • joe

              #7
              Re: A PHP/MySQL Connnector Problem

              Windows requires a reboot in order for your PATH updates to work....

              Comment

              Working...