Connecting to Microsoft SQL Server with PHP
August 9, 2007 – 12:39 pmI 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:
7 Responses to “Connecting to Microsoft SQL Server with PHP”
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
on Aug 9, 2007
I’m not using the PEAR::DB class. I wrote my own class that simply uses mssql_connect.
By Jeremy
on Aug 9, 2007
I’ve got your class
By Jack
on Aug 9, 2007
I’m glad. You need some class.
By Jeremy
on Aug 9, 2007
Why does Jon always identify himself as “Jack” when he posts online? We all know it’s him.
By Mark
on Aug 10, 2007
Jon’s a wannabe pirate.
By Jeremy
on Aug 10, 2007
ARRRRRR!!!
By Jack
on Aug 11, 2007