我需要與遠程SQL Server 2000數據庫交談。我在本地使用MAMP,我想繼續使用它。然而,我失去了我需要做什麼來增加對PHP與這個數據庫交談的支持。它看起來像PHP中的ODBC或SQL Server函數可以工作,但這些模塊默認情況下不安裝。MAMP:添加ODBC或SQL Server支持
有人可以提供有關如何添加對MAMP中的ODBC或SQL Server的支持的說明嗎?
我需要與遠程SQL Server 2000數據庫交談。我在本地使用MAMP,我想繼續使用它。然而,我失去了我需要做什麼來增加對PHP與這個數據庫交談的支持。它看起來像PHP中的ODBC或SQL Server函數可以工作,但這些模塊默認情況下不安裝。MAMP:添加ODBC或SQL Server支持
有人可以提供有關如何添加對MAMP中的ODBC或SQL Server的支持的說明嗎?
Check this question out,看起來你需要爲你的PHP版本獲取驅動程序。
這是另一個鏈接:Connecting to MS SQL server from PHP using MAMP on OSX。
我能夠得到他的工作:
摘要:
P ASTE這到你的終端:
curl -s http://php-osx.liip.ch/install.sh | bash -
(可與OS 10.7)
打開/usr/local/php5/etc/freetds.conf
在文本編輯器並在末尾添加您的MSSQL服務器的條目:
[MSHOSTNAME]
host = mshostname.example.com
port = 1433
tds version = 8.0
在您的Sites文件夾中保存一個PHP文件並激活Web共享。
<?php
$myUser = "your_name";
$myPass = "your_password";
$myDB = "examples";
//connection to the database
$dbhandle = mssql_connect(MSHOSTNAME, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT id, name, year ";
$query .= "FROM cars ";
$query .= "WHERE name='BMW'";
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
}
//close the connection
mssql_close($dbhandle);
?>
謝謝你,第二個環節是贏家! – weotch 2009-09-09 17:45:00
沒問題,開心編碼:D – Anders 2009-09-10 16:08:10
第二個鏈接死了! – bottleboot 2012-12-31 15:33:16