Using PHP to connect to SQL server 2008 ... How can I do this?

dalearyous

[H]ard|Gawd
Joined
Jun 21, 2008
Messages
1,922
I would like to connect to a Microsoft SQL Server v. 2008 ...

Typically I do this:
Code:
$connect = mysql_connect('server', username, password);
if ( !$connect )
{
	echo "Error connecting to server.\n";
}
 
Is there a good reason you're using PHP with mssql? It's like using .net with MySQL, the two just don't fit well together. My advice is to pick one or the other, its like trying so square peg a round hole.
 
Is there a good reason you're using PHP with mssql? It's like using .net with MySQL, the two just don't fit well together. My advice is to pick one or the other, its like trying so square peg a round hole.

The project we are working on right now is for a major auto industry manufacturer and they are a Microsoft house. One requirement of the project was we had to use MS SQL Server so that their backup jobs would run on it.

If he is running php on IIS this is what I installed on their server to connect with instead of the php extension:
http://www.microsoft.com/download/en/details.aspx?id=20098
 
Is there a good reason you're using PHP with mssql? It's like using .net with MySQL, the two just don't fit well together. My advice is to pick one or the other, its like trying so square peg a round hole.

I would disagree with this statement. I would choose an enterprise level database engine over MySQL any day of the week regardless of the programming language used for the front end.
 
Is there a good reason you're using PHP with mssql? It's like using .net with MySQL, the two just don't fit well together. My advice is to pick one or the other, its like trying so square peg a round hole.

I use PHP and MSSQL at work and it's a marriage that works just fine together. I develop both PHP and .NET apps that often need to share the same data, so one common DB makes my life much easier. As others have recommended, don't use the mssql driver that comes with PHP, it's outdated and requires installing the SQL admin tools in order to work. I use the Microsoft PHP drivers for MSSQL and it's awesome.

The quickest and easiest way to install PHP on IIS is with the Web Platform Installer. It installs and configures everything for you. Easy peasy.

BTW, here's a link to the Microsoft PHP Driver reference
 
Last edited:
I use PHP and MSSQL at work myself when im doing odd pages that dont use ColdFusion, PHP and MSSQL work fine together, just, as stated before by Sgraffite and LightningCrash, read up on the binding parameters.
 
I never said you can't use PHP with MSSQL, merely it's not a native environment and this can lead to odd problems with off the shelve software.

I would disagree with this statement. I would choose an enterprise level database engine over MySQL any day of the week regardless of the programming language used for the front end.

I actually know a major payment gateway using MySQL on the back end. I was talking to them about a discrepancy and the guy said "let my fire up php my admin...". :eek:

To be fair they have done allot of work on different database engines, some much better suited to high performance tasks than MSSQL, but that's another topic.
 
I never said you can't use PHP with MSSQL, merely it's not a native environment and this can lead to odd problems with off the shelve software.

I assume in this situation that he's writing his own software and not using a COTS solution.
 
To be fair they have done allot of work on different database engines, some much better suited to high performance tasks than MSSQL, but that's another topic.
If you can make concessions to data safety and/or concurrency, there are some applications where MySQL's implementation can be faster. While Oracle is making progress with the code base, MySQL isn't for heavy lifting.
 
Back
Top