I'm in the process of setting up PHP / MYSQL on a Windows Server 2003 machine, with IIS. I have installed PHP 5.3.8 and MySQL 5.5. PHP is configured to use FastCGI.
In php.ini I have the following lines uncommented:
extension=php_mysql.dll
extension=php_mysqli.dll
Here is my code:
$con = mysql_connect("127.0.0.1","root","test");
if (!$con)
{
die('Could not connect: $php_errormsg' . mysql_errno() . ": " . mysql_error(). "\n");
}
echo "connected";
?>
Here is the output:
PHP Warning: mysql_connect(): in C:\Inetpub\wwwroot\mysqltest.php on line 2
I can connect to the MYSQL database on this server from a PHP page running on another webserver - so I know that my MYSQL database is correctly accepting connections.
Any help on this would be greatly appreciated
解决方案
Apparently I had a permissions issue. I was able to resolve it by following these steps:
From Windows Explorer, I...
right-clicked on C:\Inetpub
went to Properties > Security > Permissions
selected "Replace permission entries on all child objects with entries shown here that apply to child objects"
clicked Apply
restarted IIS by running iisreset from a command prompt.