Jump to content

same php file with Mysql connection works on Apache but not on IIS


damjanko

Recommended Posts

Version
Apache 2.2.3
PHP 5.2
Windows XP

The same php file get the error on IIS

Fatal error: Call to undefined function mysql_connect() in C:\L\Site1\index.php on line 2

Same file works with apache on port localhost:8080

but not in IIS localhost

code is

<?php
$con = mysql_connect("localhost","root","sa");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("damjan", $con);

$result = mysql_query("SELECT * FROM partner");

while($row = mysql_fetch_array($result))
  {
  echo $row[0]  . " " .  $row[1] . " " . $row[2];
  echo "<br />";
  }

mysql_close($con);
?>

I Try this but still get a error

1. Open the php.ini file and make the following changes to its contents (php.ini is a text file and resides in C:\WINNT)
Change this : ;extension=php_mysql.dll
to : extension=php_mysql.dll
(the semicolon at the start is removed)
Then give the correct path to the extensions directory
extension_dir = "C:\Program_Files\php\morephp"
(in my case I created a directory called 'morephp' to store all the extensions. If your directory is called 'extensions' the line would be
extension_dir = "C:\Program_Files\php\extensions")




2) Then copy the following files in to the morephp directory (as I have mentioned above, morephp is a name I gave to a directory into which I dump all the extensions):

php_mysql.dll
php_mysqli.dll

The 2 files are available for download here

And... you should live happily ever after!

Remember to restart IIS before viewing pages.

3) Should you still face problems try this. Copy the following files

libmysql.dll
libmysqli.dll

in to

c:\windows\system32

The 2 files are available for download here


4) Still does not work? Try this slightly radical step.
Here is a dump of all the dll files you would possibly need for PHP5 installation. Simply copy all the files from this directory in to your morephp directory.
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.