我在本地服務器上有一個本地MS SQL數據庫和IIS上的Web PHP應用程序。IIS,MS SQL和PHP - 在PHP中選擇SQL不起作用
在IIS我已經成功連接PHP和我的MS SQL數據庫(添加連接字符串,我看到我的表)
但是,當我在使用PHP的Web應用程序的任何SQL選擇,這是行不通的。沒有數據顯示,或任何誤差修改,例如:
/* Connect to a MySQL database using driver invocation */
$dsn = 'mysql:dbname=dbname;host=localhost';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$results = mysql_query("SELECT id FROM users");
while($row = mysql_fetch_array($results)) {
$name = $row['id']
?>
<tr>
<td><?php echo '$name'?></td>
</tr>
<?php
}
?>
</tbody>
</table>
嘗試添加錯誤報告---- error_reporting(E_ALL); ini_set('display_errors',1); – user3663
爲什麼使用PDO進行連接,然後嘗試運行不推薦的'mysql_query'?永遠不要去工作 – RamRaider
你知道MySQL和MS SQL(或SQL Server)不是一回事嗎? [mssql_ *](http://php.net/manual/en/book.mssql.php)或只是PDO **與正確的連接字符串**是你應該使用的。 – apokryfos