【问题标题】:Connection Errors whit MSSQL over PHPMSSQL over PHP 的连接错误
【发布时间】:2016-06-30 16:53:51
【问题描述】:

我想在一个小的 .php 文件中使用一个简单的 SQL 语句。 但我的问题是我无法连接到服务器(MSSQL 2014)

错误: 警告:mssql_connect() [function.mssql-connect]:无法连接到服务器:localhost\SQLEXPRESS in

代码:

<?php

$verbindung = mssql_connect('localhost\SQLEXPRESS', '*****', '*****');

if (!$verbindung || !mssql_select_db('php', $verbindung)) {
die('Connection Failed');
}
?>

我的系统: 我使用 XAMPP-Server 1.7.0 和 PHP 5.2.8

谢谢4你的帮助:)

(您可能会保留拼写错误;P)

【问题讨论】:

  • 您能否确认您可以使用其他方法连接到服务器?
  • 我在 1 周前用 php 5.5 + 尝试了几乎相同的方法,但你需要使用 MYSQLI 函数(#bugged as crap)

标签: php mysql sql sql-server xampp


【解决方案1】:

我认为你需要转义斜线:

$verbindung = mssql_connect('localhost\\SQLEXPRESS', '*****', '*****');

【讨论】:

【解决方案2】:

知道了:D

$user = '*****';
$pass = '******';
$server = 'localhost\SQLEXPRESS';
$database = 'Account';


$connection_string = "DRIVER={SQL Server};SERVER=$server;DATABASE=$database"; 
$conn = odbc_connect($connection_string,$user,$pass);

if ($conn) {
      echo "Connection established.";
     } else{
die("Connection could not be established.");
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-13
    • 2018-02-09
    • 2013-01-02
    • 1970-01-01
    • 2019-01-11
    相关资源
    最近更新 更多