Meloria • Ever Better
Search Tools Main Menu

Using PHP to Connect to Microsoft SQL Server

Introduction | Getting Started | Limitations | More on Data Types | Troubleshooting

Introduction

PHP is a server-side web scripting language normally used to communicate with MySQL databases. However, it is also possible to use PHP to access Microsoft SQL (MS SQL) Server databases. Our Unix servers use FreeTDS to communicate with MS SQL Server databases, and this Web Help tutorial discusses how this is accomplished and the known limitations of running MS SQL queries from PHP on a Unix server.

Scope

The information in this document is largely specific to MS SQL Server 2000 databases. Although complete testing was not conducted on MS SQL Server 2005 databases, our preliminary testing suggests similar behavior to that of MS SQL Server 2000.

SQL Tutorials

If you are new to SQL, see the following tutorials online to get started.

Policy and Security

In order to Deploy a MS SQL connection script, you must check the MS SQL checkbox under your "Account Information" inside of Deploy. If this box is not checked you will not be permitted to deploy any files that contain MS SQL connection scripts. Checking this box places you on a mailing list for notifications on MS SQL-related issues.

If you do not administer the MS SQL server you will need to contact the database administrator of the system in question. (University IT/Academic & Research is responsible for most of these systems at the University.) You will need to request the following from your database administrator.

  1. You will need a username that uses SQL Server authentication to login.
  2. Mixed Authentication should be enabled on the server. (This is also called SQL Server and Windows Authentication mode)
  3. You will need user permissions on a database and a table.

Remember to use strong passwords. We strongly recommend that you use the same standards that are used on your www.wdev login password.

When you deploy any file that contains a MS SQL connection script, Deploy will automatically set the appropriate permissions on the file to best protect its contents. Deploy will also record the location of the file under "Account Information" so that we have it on record in the event of a security breech. Only you and the system administrator will have access to this information.

Please read this tutorial carefully and completely. Contact webhelp@rochester.edu for assistance.