<?php
$serverName = "(local)"; //serverName
$connectionInfo = array("Database"=>"DabaseNew", "UID"=>"sa", "PWD"=>"*****");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn==true) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die(print_r(sqlsrv_errors(), true));
}
$sql = "SELECT * FROM Dbo.DATABASE COMPANY SERVICES$Employee";
$stmt = sqlsrv_query($conn, $sql);
if(!$stmt){
die(print_r(sqlsrv_errors(), true));
}
$rows = sqlsrv_has_rows($stmt);
while($obj = sqlsrv_fetch_object($stmt)){
echo $obj->Description.", ".$obj->lName."<br />";
}
?>
我想連接到我的sql服務器使用sqlsrv_connect到PHP。上面的代碼在下面給我一個錯誤;連接PHP到MS SQL服務器
輸出: 已建立連接。 Array([0] => Array([0] => 42000 [SQLSTATE] => 42000 [1] => 102 [code] => 102 [2] => [Microsoft] [SQL Server Native Client 11.0] [ SQL Server]'SERVICES'附近語法錯誤[message] => [Microsoft] [SQL Server Native Client 11.0] [SQL Server]'SERVICES'附近的語法不正確。))
'SELECT * FROM Dbo.DATABASE公司服務$ Employee' **那是查詢?** – Abdullah
你想要什麼,從哪個數據庫,其中的條件下選擇? – Daniel
@Abdullah我希望看到表 – user3315848