我需要与远程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