【问题标题】:Getting a Error during PHP connection to mysql in webmatrix在 webmatrix 中 PHP 连接到 mysql 期间出现错误
【发布时间】:2015-12-29 08:09:55
【问题描述】:

尝试从webmatrix中的php文件连接mysql数据库时出现错误,详细信息如下

这是 PHP 文件:

<!DOCTYPE html>
<html>
<body>

<?php
$servername = "localhost";
$username = "root";
$password = "password";
$database = "image" ;

// Create connection
$conn = new mysqli($servername, $username, $password);
echo "Connected successfully";
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";
?>

</body>
</html>

这是 web.config 文件:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <connectionStrings>
        <add connectionString="Server=localhost;Database=image;Uid=root;Pwd=password" name="image" providerName="MySql.Data.MySqlClient" />     
    </connectionStrings>

</configuration>

这是我得到的错误:

HTTP Error 403.14 - Forbidden
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.

More Information:
This error occurs when a document is not specified in the URL, no default document is specified for the Web site or application, and directory listing is not enabled for the Web site or application. This setting may be disabled on purpose to secure the contents of the server.

【问题讨论】:

  • $password = "密码"; ??

标签: php mysql webmatrix


【解决方案1】:

我通过更改 web.config 文件以添加默认文档来解决此问题,如下所示

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <connectionStrings>
        <add connectionString="Server=localhost;Database=image;Uid=root;Pwd=hrushikesh" name="image" providerName="MySql.Data.MySqlClient" />     
    </connectionStrings>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="sample.php" />
            </files>
        </defaultDocument>
    </system.webServer>

</configuration>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-18
    • 1970-01-01
    • 2017-08-11
    • 2019-03-08
    • 2021-08-10
    • 1970-01-01
    • 2019-07-25
    相关资源
    最近更新 更多