Jump to content

That old saw - PHP, MySQL, and IIS


Recommended Posts

I'm trying to get the MySql extension working on a Windows machine using IIS.

 

I've looked at numerous tutorials, including several threads on these forums already, and can't get the $%#!@ing thing to work.

 

Here's what I've done so far.

 

1. In php.ini, I've set the extension_dir variable to "C:\php\ext"

2. I've added extension = "php_mysql.dll" to php.ini

3. I've added "C:\php" to the PATH environment variable so that the computer should be able to find libmysql.dll

3a. I also tried copying libmysql.dll to "C:\WINDOW\System32", but that didn't work either

4. Restarted both IIS and the server numerous times.

 

I know that I'm editing the right php.ini file, because other changes I've made have been working just fine.  For example, turning on display_errors (this is a test server).

 

It's still not working, and I don't know what the deal is.  Have I missed anything blazingly obvious?

Link to comment
Share on other sites

What errors or other symptoms are you getting that makes you think it is not working? Posting your actual errors might give someone a clue as to what might be wrong.

 

Have you checked your web server log for errors (in IIS I believe it is the Windows system event log.)

Link to comment
Share on other sites

Make sur php_mysql.dll that came with PHP are of the same build (version) as php.exe.

 

If they are the same build, Then I think you may have an older libmysql.dll (or php_mysql.dll maybe) laying about somewhere on your hardrive which is maybe stopping the mysql extension from loading. Got to Start > Search and search for a file called libmysql.dll let is scan the whole of you computer.

 

Windows should only return two results, which are:

- libmysql.dll in the root of your PHP folder

- libmySQL.dll located in your MySQL bin folder.

 

If Windows finds any others either delete them or rename them. Repeat the process for php_mysql.dll too only one result should be returned.

Link to comment
Share on other sites

What errors or other symptoms are you getting that makes you think it is not working? Posting your actual errors might give someone a clue as to what might be wrong.

 

Have you checked your web server log for errors (in IIS I believe it is the Windows system event log.)

 

This is just a page I have to test whether the MySql extension is working.

 

Source code:

<html>
<head>
<title>
</title>
</head>

<body>

<pre>
Grrr.  Work!
<?php



echo "test\n";
echo "moo\n";

echo $a; // reference an undefined variable to make sure display_errors is on

print_r($_GET);

$connection = mysql_connect('localhost', 'root', '***'); // password obfuscated

$db = mysql_select_db('test', $connection);



$sql = "SELECT * FROM waste;";

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result))
{
  print_r($row);
}
?>

</pre>
</body>
</html>

 

Output:

 

Grrr.  Work!

test

moo

 

 

Notice:  Undefined variable: a in C:\Inetpub\wwwroot\sqltest.php on line 20

 

Array

(

    [foo] => bar

)

 

 

Fatal error:  Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\sqltest.php on line 24

Link to comment
Share on other sites

Make sur php_mysql.dll that came with PHP are of the same build (version) as php.exe.

 

If they are the same build, Then I think you may have an older libmysql.dll (or php_mysql.dll maybe) laying about somewhere on your hardrive which is maybe stopping the mysql extension from loading. Got to Start > Search and search for a file called libmysql.dll let is scan the whole of you computer.

 

Windows should only return two results, which are:

- libmysql.dll in the root of your PHP folder

- libmySQL.dll located in your MySQL bin folder.

 

If Windows finds any others either delete them or rename them. Repeat the process for php_mysql.dll too only one result should be returned.

PHP, MySql and IIS were all installed for the first time on this server last week.  There are no other copies of libmysql.dll or php_mysql.dll lying around anywhere on the hard drive, and the only version I have is the one that came with the newly installed version of PHP.

Link to comment
Share on other sites

Since there does not appear to be any errors related to reading or finding any of the .dll's, I suspect that php has not attempted to load them yet.

 

After making any change to php.ini, you need to stop and start the whole IIS service (in the control panel "services" manager) or reboot the whole computer. Just stopping and starting the web site in the IIS management console does not cause php to read the php.ini.

Link to comment
Share on other sites

One step that I don't see in your list is the IUSR_account_name that the web server is running under must have permission to read the php folder and its sub-folders.

 

    * The IIS user (usually IUSR_MACHINENAME) needs permission to read

      various files and directories, such as php.ini, docroot, and the

      session tmp directory.

Link to comment
Share on other sites

I don't see yet if you checked the web server log for errors?

 

If the php_mysql.dll file is present in the ext folder and the php.ini settings for extension_dir and extension = php_mysql.dll are in the php.ini and php is reading the php.ini and the path to php is in your Windows path so the auxiliary files (I think there are actually two needed for mysql) can be found, and all the permissions are correct, this should work. I would recheck that all the files exist where you think they are. Perhaps copying files actually resulted in them being moved.

 

Is there a reason you are using IIS instead of Apache?

Link to comment
Share on other sites

All the right files seem to be in the right place, so I'm just as confused as you are.

 

I didn't do the initial setup on the server.  One of our IT guys did.  Pretty much all of his experience is using Windows, so he went with what he knew.  I could uninstall IIS and install Apache instead, but then I would be the only person who knew how the hell it worked.  Since I'm not part of IT, that probably wouldn't be the best thing.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.