Connecting Tech Pros Worldwide Help | Site Map

mssql_connect blank

Newbie
 
Join Date: Oct 2008
Posts: 1
#1: Oct 25 '08
Hello,

This is a strange one! I'm getting blank results for mssql_connect. I created a simple testmssql.php page with the following code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if (function_exists('mssql_connect')) {
  3. die("Your PHP installation does not have MSSQL support.");
  4. }
  5.  
  6. echo "Connecting...";
  7. echo "<BR>";
  8.  
  9. $hostname = "ServerName";
  10. $username = "UserName";
  11. $password = "pwd";
  12.  
  13. $db = mssql_connect ($hostname, $username, $password);
  14.  
  15. if ($db){
  16. echo "no connection";
  17. }else{
  18. echo "connected";
  19. }
  20.  
  21. ?>
Here's the strange part:
1) I get a blank respone for mssql_connect function
2) Even, stranger, if I shut down IIS, this works like a charm!!

My Environment:
PHP 5.2.6.6 (Installed C:\Program Files\PHP)
IIS 6.0 (Windows Server 2003)
.php configured to ""C:\Program Files\PHP\php-cgi.exe", All Verbs, Script Engine checked.

Any ideas?

Thanks!
M

Troubleshooting Step:
I removed the @ from @mssql_connect and I get the following error:
PHP Fatal error: Call to undefined function mssql_connect() in ..... line 15.
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,095
#2: Oct 28 '08

re: mssql_connect blank


Get linux or get Apache. Dropping IIS will save you lots of headaches in the future as well.
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#3: Oct 28 '08

re: mssql_connect blank


I believe your logic is flawed: function_exists() returns true or false depending on whether the function exists - just as the name implies. You, however, check if the function exists and if it does you kill the script! Maybe that's not the problem, because you should get errors either way.

Using PHP on IIS never seemed logical to me: this is M$ we're talking about, and when have they ever catered to others needs?
Reply