如何使用php连接到sql server?
$server = "MySQLSERVER";
$conn = mysqli_connect($server,'sa','11111111');
if (!$conn)
{
die("Something went wrong while connecting to MSSQL");
}
此代码给出结果:
警告:mysqli_connect():( HY000 / 1130):主机'kpadilla.rafi.local'是 不允许连接到此MariaDB服务器 第5行的D:\ xampp \ htdocs \ sample \ sample.php
答案 0 :(得分:0)
您必须使用mssql_connect
函数而不是mysqli_connect
,因为您尝试连接 MSSQL Server 。 (首先安装mssql扩展:http://php.net/manual/en/mssql.installation.php)
$conn = mssql_connect($server,'sa','11111111');
if (!$conn)
{
die("Something went wrong while connecting to MSSQL");
}
答案 1 :(得分:0)
你应该使用mssql_connect:
http://php.net/manual/de/function.mssql-connect.php
$conn = mssql_connect($server, $user, $password);