Connecting to Microsoft SQL Server with PHP

August 9, 2007 – 12:39 pm

I decided to be secure and came up with a 33 character password for a MS SQL Server account. After writing a settings file for my new PHP blog application and a DB class I tried to connect. No go. The permissions were checked and everything looked fine. I tried my personal user name and password and was able to connect successfully. What was wrong?! I used SQL Server Query Analyzer to connect with my 33 character application password and it worked perfectly. Strange. After much deliberation, I thought, “Hmm…I wonder if there’s a maximum password length when connecting to SQL Server via PHP.” Sure enough, the maximum length is 30 characters. Blah to you, PHP. Next time how about a better error message than “login failed for user…”?.



Was this helpful? Check out these related posts:

  1. Retrieving Text Data from SQL Server 2000 Using PHP
  2. Install SSH Server on Ubuntu
  3. SQL Server Query Analyzer Results to Excel (TSV)

  1. 7 Responses to “Connecting to Microsoft SQL Server with PHP”

  2. you should also note that you’re using the PEAR/DB class to connect… it could be a limitation of that class’ function.

    By Mark UNITED STATES Mac OS X Mozilla Firefox 2.0.0.6 on Aug 9, 2007

  3. I’m not using the PEAR::DB class. I wrote my own class that simply uses mssql_connect.

    By Jeremy UNITED STATES Windows XP Mozilla Firefox 2.0.0.6 on Aug 9, 2007

  4. I’ve got your class

    By Jack UNITED STATES Mac OS X Mozilla Firefox 2.0.0.6 on Aug 9, 2007

  5. I’m glad. You need some class. :D

    By Jeremy UNITED STATES Windows XP Mozilla Firefox 2.0.0.6 on Aug 9, 2007

  6. Why does Jon always identify himself as “Jack” when he posts online? We all know it’s him.

    By Mark UNITED STATES Mac OS X Mozilla Firefox 2.0.0.6 on Aug 10, 2007

  7. Jon’s a wannabe pirate.

    By Jeremy UNITED STATES Windows XP Mozilla Firefox 2.0.0.6 on Aug 10, 2007

  8. ARRRRRR!!!

    By Jack UNITED STATES Mac OS X Mozilla Firefox 2.0.0.6 on Aug 11, 2007

Post a Comment