[UPHPU] Connecting to mssql through php???

Mac Newbold mac at macnewbold.com
Tue Mar 17 20:08:07 MDT 2009


Today at 6:08pm, Brady Mitchell said:

> On Tue, Mar 17, 2009 at 1:03 PM, Caleb Call <caleb at macjunk.net> wrote:
>> I'm trying to use mssql_connect, but I'm not opposed to using another method of
>> connecting if it's better.  Any help would be appreciated.
>
> I've only used MS SQL and PHP together once, and I was never able to
> get it working using the built-in functions on their own. Using adodb
> (http://adodb.sourceforge.net/) worked well for me:
>
> $conn =& ADONewConnection('odbc_mssql');
> $conn->Connect($dsn_name,$db_user,$db_passwd);

The two main methods (not counting things that layer on top of them, like 
adodb) are directly (MSSQL extension) and ODBC (ODBC extension). From a 
linux box you usually need FreeTDS as well (especially for MSSQL method) 
but in this case that won't be necessary.

Generally there's some installation to do to make sure you have compatible 
versions of all the DLLs. Last I checked, the online resources, starting 
with php.net user comments in the manual, and following up with Google, 
gave good answers and chances are really good someone else ran into any 
problem you ran into and documented a solution eventually.

Last time we set up an MS SQL connection on a windows box from PHP I think 
we eneded up needing to use ODBC because the direct way was never happy 
with the versions of DLLs we had (aka DLL Hell, one program needs one 
version and another program can't work with that version). With ODBC there 
are a bunch of connections you need to configure before it works, if I 
remember right. There's a level of that with the "direct" way too.

Thanks,
Mac

--
Mac Newbold			Code Greene, LLC
CTO/Chief Technical Officer	44 Exchange Place
Office:	801-582-0148		Salt Lake City, UT  84111
Cell:	801-694-6334		www.codegreene.com


More information about the UPHPU mailing list