Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在webmatrix中PHP连接到mysql时出错_Php_Mysql_Webmatrix - Fatal编程技术网

在webmatrix中PHP连接到mysql时出错

在webmatrix中PHP连接到mysql时出错,php,mysql,webmatrix,Php,Mysql,Webmatrix,我在尝试从webmatrix中的php文件连接到mysql数据库时出错,详细信息如下 这是PHP文件: <!DOCTYPE html> <html> <body> <?php $servername = "localhost"; $username = "root"; $password = "password"; $database = "image" ; // Create connection $conn = new mysqli($serve

我在尝试从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=hrushikesh" name="image" providerName="MySql.Data.MySqlClient" />     
    </connectionStrings>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="sample.php" />
            </files>
        </defaultDocument>
    </system.webServer>

</configuration>

$password=“password”??
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.
<?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>