views:

182

answers:

1

I've successfully tested a connection via PHP's odbc_connect() to a SQL Server 2005 Express database on a Windows Vista box using the following code:

$connect = odbc_connect("mssqllocal2", "", ""); 
// first arg is the System DSN that I configured on Windows

This connection works fine when executed from an instance of WAMPserver on the same Windows box. However, I'd like to be able to connect to the same ODBC DSN from another machine on the same LAN--in this particular case, an iMac running MAMP and OS X 10.5. Ultimately, I'd like to be able to connect to the same DSN from a remote server, but that's later in the project.

Is there some syntax like this that I can use:

$connect = odbc_connect("192.168.0.55:mssqllocal2", "", "");

...or am I misunderstanding some basic tenet of ODBC data sources?

+1  A: 

There may be some way to do a direct connection to another machine like that but you might also try to download ODBC Administrator from http://support.apple.com/downloads/ODBC_Administrator_Tool_for_Mac_OS_X and use that to configure the datasource pointing over to your Windows machine. Then you use that local DSN in your php code. So basically the network communication is configured at the ODBC level rather than in your PHP code.

Jason
Ah, so I *was* misunderstanding some basic tenet of ODBC data sources.
peterjmag
oh, you also would need the appropriate ODBC drivers for MS SQL Server installed on the OSX system. there's a lot of vendors that sell them, you maybe able to find a free one as well. google for "osx odbc driver for microsoft sql server"
Jason