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:
<?php
$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
要查看连接错误,可以打印mysql_error
的输出。
$con = mysql_connect("localhost","root","test") or die('cannot connect : '. mysql_error());
Apparently I had a permissions issue. I was able to resolve it by following these steps:
From Windows Explorer, I...
iisreset
from a command prompt.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.