Link to home
Start Free TrialLog in
Avatar of rappermas
rappermas

asked on

Configuing PHP and MySQL to work together on Windows

I'm on Windows ME, running the Abyss Web Server, which I have successfully configured to use PHP.  However, what I can't do is make PHP communicate with MySQL.  Everytime I try to use a MySQL function from PHP, I get the following error:

Call to undefined function mysql_connect()

or some similar error that says the function is undefined.

I don't know what to do.  I have searched the internet for a few days now without success (all of the solutions that I found didn't work).  I installed PHP and MySQL through executable binaries, so I couldn't have configured them at installation time to work together.  My version of PHP is 5.0 and my version of MySQL is 4.0.20a.  I'm hoping that someone can help me.  Thank you ahead of time to whoever cracks this mystery.
Avatar of akshah123
akshah123
Flag of United States of America image

check your php.ini file

make sure that following line is not comments out.

The behaviour of these functions is affected by settings in php.ini.


Table 1. MySQL Configuration Options

Name Default Changeable
mysql.allow_persistent "On" PHP_INI_SYSTEM
mysql.max_persistent "-1" PHP_INI_SYSTEM
mysql.max_links "-1" PHP_INI_SYSTEM
mysql.default_port NULL PHP_INI_ALL
mysql.default_socket NULL PHP_INI_ALL
mysql.default_host NULL PHP_INI_ALL
mysql.default_user NULL PHP_INI_ALL
mysql.default_password NULL PHP_INI_ALL
mysql.connect_timeout "0" PHP_INI_SYSTEM

For further details and definition of the PHP_INI_* constants see ini_set().

Here's a short explanation of the configuration directives.



mysql.allow_persistent boolean


check out
http://us2.php.net/manual/en/ref.mysql.php
for more info.
Avatar of j79
j79


It looks like you don't have set/install the mysql-dll for php.
Your php.ini (in your Windows directory) should have an entry poiniting to the place where your mysql-dll is.
e.g.: php_mysql.dll

Look if you have the mysql-dll anywhere.

j79


The MSSQL extension is enabled by adding extension=php_mssql.dll to php.ini.

To get these functions to work, you have to compile PHP with --with-mssql[=DIR], where DIR is the FreeTDS install prefix. And FreeTDS should be compiled using --enable-msdblib.

check your php.ini file you probably have extension=php_mssql.dll commented out.

check out https://www.experts-exchange.com/questions/21067460/Fatal-error-Call-to-undefined-function-mssql-connect.html
for more info.
Avatar of rappermas

ASKER

None of that works for me.  Like I said, I am on Windows.  I installed through pre-compiled binaries.  I could compile it, but I'm not on UNIX, so I don't have a gunzip utility or make.  That's my whole problem.  I already have everything installed, but they don't work together.  Like I said, this question is virtually unsolveable, but I still would appreciate any help.  I don't know where to find php_mysql.dll, since PHP didn't come with it, and neither did MySQL.  I searched all of the hard drives on my computer for it, and it's no where to be found.
ASKER CERTIFIED SOLUTION
Avatar of j79
j79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wait, I don't get it.  When I uncomment it, I get internal server errors.  PHP works fine without MySQL, in fact, I have already set it up to use MS Access, until I realized that MS Access is a great failure in program design.  So, I decided to use MySQL, which supports long text, which is what I need, without luck.  Right now, PHP works like it should with MS Access, but I want it to use MySQL.  And, like I said, when I uncomment that line:

extension=php_mysql.dll

I get internal server errors (Error 500).  When it is commented, PHP works, but MySQL functions don't.  I don't know where to get the dll file for MySQL, and even if I do get it, where would I put it?

As I said above, the "mysql-dll" is built in the php versions above 4.0.5. So you don't need to download it.
For the error500 should give any logfiles at your webserver, which usually says something more about the problem.

j79

Another point... why do you don't use apache2 for windows which is more used with php/mysql?!

j79
I think that what I'm trying to do can't be done.  Thanks for trying to help anyway.
I've just struck the same problem...

The problem is that php_mysql.dll does appear to be not present in the current windows installer version of php 5's (I'm using php 5.0.2, 5.0.3 is the current tip).

The solution to that problem is to download the zip version from http://www.php.net, the extract php_mysql.dll to the php folder, ie where php-cgi.exe are. Watch out for zip extracting into the ext subfolder.

To get php to load the dll, go into the windows directory and uncomment the extention like for php_mysql.dll.

However I then had a second problem. I'm running mysql 4.1.4 (tip is 4.1.8), and when running php-cgi.exe (or webpages in IIS), I got a missing dll linkage from php_mysql.dll to the function mysql_drop_db. The docs say it has been deprecated, but it doesn't look like php has been reading the docs recently.

The (partially tested) solution to that was to go back to the highest mysql that did have that in libmysql.dll. Turns out to be 3.23.58. Extract the bin/libmysql.dll into php folder (again making sure you don't get the path extracted).

By doing it into there rather than the windows directories (a blatantly stupid idea anyway) or into a directory on the path, means that the mysql can run on 4.1, but php loads the local directory version (default behaviour for DLL's & EXE's) and talks to 3.23 mysql.

This works because libmysql doesn't bind to anything except a couple of system DLL's and talks using network protocols to the server engine. Now it may be that I find a couple of functions that won't work because the support isn't present in the running mysql server. However I'm willing to bet that some programmer has forgotten to correctly put a #define into libmysql.dll when building it.

Try that and see how it goes.
CGI mode. Follow the instructions below to install PHP in the CGI mode.

Edit the following lines in the php.ini file:
cgi.force_redirect = 0
cgi.redirect_status_env = ENV_VAR_NAME

These lines are security settings. If you leave these lines as they are, it prevents PHP from running in CGI mode. To enable PHP, you can either set a system variable (ENV_VAR_NAME) that PHP will look up before it runs or you can force PHP to run with cgi.force.redirect = 0.

Set up IIS so that IIS will serve PHP scripts.
Open IIS in the Microsoft Management Console MMC (usually Start > Administrative Tools > Internet Services Manager) and select a web server and website instance. (If you have multiple instances and wish to run PHP on all of the instances, you may install PHP to the master instance—Default Web Site.)
Right click the website instance, select properties from the context menu, and click the Home Directory tab.
Click the Configuration button and the Add button.
For the Executable, use the browse button or type the path to your php.exe file within the PHP folder. (For instance, in this article, the path is C:\PHP\PHP.exe.)
In the Extension Type, type the file extension that the server should use to refer to PHP scripts (this is commonly the .php extension).