使用PHP与webmatrix数据库交互

时间:2013-05-03 07:15:46

标签: php sql database connection webmatrix

我在使用Webmatrix数据库时遇到问题。我想用PHP编写的注册页面将数据插入数据库。

创建数据库时,创建了“web.config”文件。如何使用PHP中“web.config”文件中的connectionString来连接数据库?

来自我的web.config文件的连接字符串:

     <connectionStrings>
    <add connectionString="server=localhost;uid=root;database=sitedetest;Pwd=123" name="sitedetest" providerName="MySql.Data.MySqlClient" />
</connectionStrings>

我试过了:

的config.php

       <?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '123';
$dbname = 'sitedetest';
?>

在注册页面中:

include 'config.php';
    $conn = mysql_connect($dbhost,$dbuser,$dbpass)
        or die ('Error connecting to mysql');
    mysql_select_db($dbname);

但是当我尝试使用注册表时,我总是得到'错误连接到mysql'消息

感谢您的时间

0 个答案:

没有答案
相关问题