470,815 Members | 1,090 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

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

Jul 17 '05 #1
8 2487
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.
JW

Jul 17 '05 #2
On Sun, 1 Aug 2004 14:10:30 +0200, "Janwillem Borleffs" <jw@jwscripts.com>
wrote:
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.


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 <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #3
"Wilfred Johnson" <wj****@yahoo.com> wrote in message
news:f7********************************@4ax.com...
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.


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.
Jul 17 '05 #4
On Sun, 01 Aug 2004 13:41:39 +0100, Andy Hassall <an**@andyh.co.uk> wrote:
On Sun, 1 Aug 2004 14:10:30 +0200, "Janwillem Borleffs" <jw@jwscripts.com>
wrote:
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.


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.


(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_mysql.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 <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #5

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 <an**@andyh.co.uk>
wrote:
On Sun, 01 Aug 2004 13:41:39 +0100, Andy Hassall <an**@andyh.co.uk> wrote:
On Sun, 1 Aug 2004 14:10:30 +0200, "Janwillem Borleffs" <jw@jwscripts.com>
wrote:
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.


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.


(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_mysql.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.


Jul 17 '05 #6
On Sun, 01 Aug 2004 10:45:13 -0400, Wilfred Johnson <wj****@yahoo.com> wrote:
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?


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.mysql.dll directives are the only
two that are actually relevant to getting MySQL support going.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #7

Great. Now it works. Thanks for your help.
On Sun, 01 Aug 2004 16:06:40 +0100, Andy Hassall <an**@andyh.co.uk>
wrote:
On Sun, 01 Aug 2004 10:45:13 -0400, Wilfred Johnson <wj****@yahoo.com> wrote:
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?


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.mysql.dll directives are the only
two that are actually relevant to getting MySQL support going.


Jul 17 '05 #8
Wilfred Johnson wrote:
Great. Now it works. Thanks for your help.


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.
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by philippe Tressard | last post: by
10 posts views Thread by Alvaro G Vicario | last post: by
19 posts views Thread by Michael | last post: by
3 posts views Thread by Jim Michaels | last post: by
1 post views Thread by Swincher | last post: by
14 posts views Thread by brett | last post: by
5 posts views Thread by scorpionbilli | last post: by
8 posts views Thread by Kjell Pettersen | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.