Can't get mysql_connect() to work in windows

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

    Can't get mysql_connect() to work in windows

    I thought that I'd try php / mysql on windows 2000. I am running php
    5.0.0 and it works fine, except when I try to use mysql functions. I
    get:

    Fatal error: Call to undefined function mysql_connect() in ...

    The documentation is unclear to me. It says that mysql support is now
    built in, but it doesn't work. Google searches say that it's not (yet)
    built in as of a year ago. Some say that you need to compile it
    yourself. I looked into compiling it, but there are a lot of .dsw file
    and I'm not sure which one need to be compiled, plus when I did try to
    compile one of them, I got an error message about missing header files
    and missing .dsp files.

    So, can you or can you not use mysql fuctions with the windows binary
    distribution of 5.0.0? There is a lot of conflicting information out
    there.


    thanks,
    Wilfred

  • Janwillem Borleffs

    #2
    Re: Can't get mysql_connect() to work in windows

    Wilfred Johnson wrote:[color=blue]
    > So, can you or can you not use mysql fuctions with the windows binary
    > distribution of 5.0.0? There is a lot of conflicting information out
    > there.
    >[/color]

    Yes you can, but you will have to use the php_mysql.dll from one of the
    latest 4.x branches as it is no longer bundled with the release of PHP 5.


    JW



    Comment

    • Andy Hassall

      #3
      Re: Can't get mysql_connect() to work in windows

      On Sun, 1 Aug 2004 14:10:30 +0200, "Janwillem Borleffs" <jw@jwscripts.c om>
      wrote:
      [color=blue]
      >Wilfred Johnson wrote:[color=green]
      >> So, can you or can you not use mysql fuctions with the windows binary
      >> distribution of 5.0.0? There is a lot of conflicting information out
      >> there.[/color]
      >
      >Yes you can, but you will have to use the php_mysql.dll from one of the
      >latest 4.x branches as it is no longer bundled with the release of PHP 5.[/color]

      The OP has pointed out correctly that there's a load of conflicting
      information; unfortunately I think you've just added some more :-(
      php_mysql.dll is most certainly still bundled.

      The release notes say that the _MySQL client library_ (NOT to be confused with
      the PHP MySQL extension library php_mysql.dll) is no longer bundled, however
      even this does not appear to be true for the Windows binary distribution. (It's
      true for the Unix source distribution).

      I'm reinstalling 5.0.0 from the .zip file at the moment and trying to work out
      exactly what it's got; I'll post later on the results, but so far it looks
      like:

      (a) php_mysql.dll is included, as expected.
      (b) libmysql.dll is included, which is unexpected, as it was alledged to be
      removed.
      (c) The included php_mysql.dll is an old one from PHP4 that won't load in PHP5.

      Point (c) looks very odd, I'm trying to work out what's happened there.

      --
      Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
      http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

      Comment

      • Chung Leong

        #4
        Re: Can't get mysql_connect() to work in windows

        "Wilfred Johnson" <wj5437@yahoo.c om> wrote in message
        news:f7mpg0deqo d8hn7lqucobm5o1 opa7f7sfl@4ax.c om...[color=blue]
        > I thought that I'd try php / mysql on windows 2000. I am running php
        > 5.0.0 and it works fine, except when I try to use mysql functions. I
        > get:
        >
        > Fatal error: Call to undefined function mysql_connect() in ...
        >
        > The documentation is unclear to me. It says that mysql support is now
        > built in, but it doesn't work. Google searches say that it's not (yet)
        > built in as of a year ago. Some say that you need to compile it
        > yourself. I looked into compiling it, but there are a lot of .dsw file
        > and I'm not sure which one need to be compiled, plus when I did try to
        > compile one of them, I got an error message about missing header files
        > and missing .dsp files.
        >
        > So, can you or can you not use mysql fuctions with the windows binary
        > distribution of 5.0.0? There is a lot of conflicting information out
        > there.[/color]

        MySQL support is not enabled by default on PHP5 on Windows because two MySQL
        modules are bundled with the new version, php_mysql.dll and php_mysqli.dll.
        You need to enable one or the other in php.ini.

        If you're new to PHP, don't use PHP5. Install the more stable, more polished
        PHP4.3 releases instead.


        Comment

        • Andy Hassall

          #5
          Re: Can't get mysql_connect() to work in windows

          On Sun, 01 Aug 2004 13:41:39 +0100, Andy Hassall <andy@andyh.co. uk> wrote:
          [color=blue]
          >On Sun, 1 Aug 2004 14:10:30 +0200, "Janwillem Borleffs" <jw@jwscripts.c om>
          >wrote:
          >[color=green]
          >>Wilfred Johnson wrote:[color=darkred]
          >>> So, can you or can you not use mysql fuctions with the windows binary
          >>> distribution of 5.0.0? There is a lot of conflicting information out
          >>> there.[/color]
          >>
          >>Yes you can, but you will have to use the php_mysql.dll from one of the
          >>latest 4.x branches as it is no longer bundled with the release of PHP 5.[/color]
          >
          > The OP has pointed out correctly that there's a load of conflicting
          >information; unfortunately I think you've just added some more :-(
          >php_mysql.dl l is most certainly still bundled.
          >
          > The release notes say that the _MySQL client library_ (NOT to be confused with
          >the PHP MySQL extension library php_mysql.dll) is no longer bundled, however
          >even this does not appear to be true for the Windows binary distribution. (It's
          >true for the Unix source distribution).
          >
          > I'm reinstalling 5.0.0 from the .zip file at the moment and trying to work out
          >exactly what it's got; I'll post later on the results, but so far it looks
          >like:
          >
          >(a) php_mysql.dll is included, as expected.
          >(b) libmysql.dll is included, which is unexpected, as it was alledged to be
          >removed.
          >(c) The included php_mysql.dll is an old one from PHP4 that won't load in PHP5.
          >
          > Point (c) looks very odd, I'm trying to work out what's happened there.[/color]

          (c) was my fault, I had an older php5ts.dll knocking around. I've sorted that.


          PHP 5.0.0 Windows binary .zip distribution includes both the PHP MySQL
          extension, php_mysql.dll in the ext/ directory, and a MySQL client library
          libmysql.dll in the top-level PHP directory, from MySQL version 3.23.57.

          (The official MySQL library filename, and the one that php_mysql.dll is linked
          against, is libmySQL.dll, uppercase SQL, however since this is Windows, case
          doesn't matter, so the supplied one works fine).

          To get MySQL support working:

          * Iinstall PHP as normal from the .zip distribution.

          * Edit php.ini, setting extension_dir correctly (to the full path to the ext
          directory) and uncomment the extension=php_m ysql.dll line.

          * Ensure that the top-level PHP directory is on your PATH environment variable
          (as seen by your webserver) or copy libmySQL.dll to somewhere that already is
          (preferably NOT your Windows directories).

          * Start PHP, check phpinfo() and you should see MySQL functions are available.

          This works entirely from the PHP 5.0.0 Windows binary .zip distribution with
          no additional software required. I've also verified the functions actually work
          by connecting to and querying a MySQL database.

          Hope this clears up the situation a bit.

          --
          Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
          http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

          Comment

          • Wilfred Johnson

            #6
            Re: Can't get mysql_connect() to work in windows


            There is no php.ini when I unzip the zip file.

            There is a php.ini-dist and php.ini-recomended.
            Do I copy one of these to php.ini? Which one?

            thanks,
            Wilfred


            On Sun, 01 Aug 2004 14:19:56 +0100, Andy Hassall <andy@andyh.co. uk>
            wrote:
            [color=blue]
            >On Sun, 01 Aug 2004 13:41:39 +0100, Andy Hassall <andy@andyh.co. uk> wrote:
            >[color=green]
            >>On Sun, 1 Aug 2004 14:10:30 +0200, "Janwillem Borleffs" <jw@jwscripts.c om>
            >>wrote:
            >>[color=darkred]
            >>>Wilfred Johnson wrote:
            >>>> So, can you or can you not use mysql fuctions with the windows binary
            >>>> distribution of 5.0.0? There is a lot of conflicting information out
            >>>> there.
            >>>
            >>>Yes you can, but you will have to use the php_mysql.dll from one of the
            >>>latest 4.x branches as it is no longer bundled with the release of PHP 5.[/color]
            >>
            >> The OP has pointed out correctly that there's a load of conflicting
            >>information ; unfortunately I think you've just added some more :-(
            >>php_mysql.d ll is most certainly still bundled.
            >>
            >> The release notes say that the _MySQL client library_ (NOT to be confused with
            >>the PHP MySQL extension library php_mysql.dll) is no longer bundled, however
            >>even this does not appear to be true for the Windows binary distribution. (It's
            >>true for the Unix source distribution).
            >>
            >> I'm reinstalling 5.0.0 from the .zip file at the moment and trying to work out
            >>exactly what it's got; I'll post later on the results, but so far it looks
            >>like:
            >>
            >>(a) php_mysql.dll is included, as expected.
            >>(b) libmysql.dll is included, which is unexpected, as it was alledged to be
            >>removed.
            >>(c) The included php_mysql.dll is an old one from PHP4 that won't load in PHP5.
            >>
            >> Point (c) looks very odd, I'm trying to work out what's happened there.[/color]
            >
            > (c) was my fault, I had an older php5ts.dll knocking around. I've sorted that.
            >
            >
            > PHP 5.0.0 Windows binary .zip distribution includes both the PHP MySQL
            >extension, php_mysql.dll in the ext/ directory, and a MySQL client library
            >libmysql.dll in the top-level PHP directory, from MySQL version 3.23.57.
            >
            > (The official MySQL library filename, and the one that php_mysql.dll is linked
            >against, is libmySQL.dll, uppercase SQL, however since this is Windows, case
            >doesn't matter, so the supplied one works fine).
            >
            > To get MySQL support working:
            >
            >* Iinstall PHP as normal from the .zip distribution.
            >
            >* Edit php.ini, setting extension_dir correctly (to the full path to the ext
            >directory) and uncomment the extension=php_m ysql.dll line.
            >
            >* Ensure that the top-level PHP directory is on your PATH environment variable
            >(as seen by your webserver) or copy libmySQL.dll to somewhere that already is
            >(preferably NOT your Windows directories).
            >
            >* Start PHP, check phpinfo() and you should see MySQL functions are available.
            >
            > This works entirely from the PHP 5.0.0 Windows binary .zip distribution with
            >no additional software required. I've also verified the functions actually work
            >by connecting to and querying a MySQL database.
            >
            > Hope this clears up the situation a bit.[/color]

            Comment

            • Andy Hassall

              #7
              Re: Can't get mysql_connect() to work in windows

              On Sun, 01 Aug 2004 10:45:13 -0400, Wilfred Johnson <wj5437@yahoo.c om> wrote:
              [color=blue]
              >There is no php.ini when I unzip the zip file.
              >
              >There is a php.ini-dist and php.ini-recomended.
              >Do I copy one of these to php.ini? Which one?[/color]

              Good point, I didn't mention that step as I just did it out of habit.

              Either is fine. I used php.ini-dist (which is more suited for development,
              e.g. errors displayed in the output) rather than php.ini-recommended (which is
              more suited for production, e.g. errors logged to error log), but the
              extension_dir=/path/to/ext and extension=php.m ysql.dll directives are the only
              two that are actually relevant to getting MySQL support going.

              --
              Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
              http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

              Comment

              • Wilfred Johnson

                #8
                Re: Can't get mysql_connect() to work in windows


                Great. Now it works. Thanks for your help.


                On Sun, 01 Aug 2004 16:06:40 +0100, Andy Hassall <andy@andyh.co. uk>
                wrote:
                [color=blue]
                >On Sun, 01 Aug 2004 10:45:13 -0400, Wilfred Johnson <wj5437@yahoo.c om> wrote:
                >[color=green]
                >>There is no php.ini when I unzip the zip file.
                >>
                >>There is a php.ini-dist and php.ini-recomended.
                >>Do I copy one of these to php.ini? Which one?[/color]
                >
                > Good point, I didn't mention that step as I just did it out of habit.
                >
                > Either is fine. I used php.ini-dist (which is more suited for development,
                >e.g. errors displayed in the output) rather than php.ini-recommended (which is
                >more suited for production, e.g. errors logged to error log), but the
                >extension_di r=/path/to/ext and extension=php.m ysql.dll directives are the only
                >two that are actually relevant to getting MySQL support going.[/color]

                Comment

                • Sebastian Lauwers

                  #9
                  Re: Can't get mysql_connect() to work in windows

                  Wilfred Johnson wrote:
                  [color=blue]
                  > Great. Now it works. Thanks for your help.[/color]

                  Great.

                  But i was wondering, this question is getting repeated a lot. Isn't
                  PHP.net planning to give more info about that? Why don't they bundle the
                  mysql client anymore (linux) ? Is it because of MySQL went to GNU (maybe
                  GPL don't remember). I don't understand why they don't give more info
                  about all this.

                  I'm afraid this question is going to be asked a hell lot of times.

                  Comment

                  Working...