here is an overview of what we have setup.
I am a scripting newb...

Windows 2003 web server with php installed and appears to be working with a vairied amount of php speciifc scripts that work fine.

Windows 2003 with SQL 2005 database server. Databases can be accessed thru 100+ machines perfectly with the sql client tools.

Now all im trying to do is connect to the database server and post whatever info is in the table using php.

here is my coding:

<?
$server="tech-db,1433";
$username="php25";
$password="tech214";
$sqlconnect=mssql_connect($server, $username, $password);
$sqldb=mssql_select_db("php25",$sqlconnect);
$sqlquery="SELECT title FROM book;";
$results= mssql_query($sqlquery);
while ($row=mssql_fetch_array($results)){
echo $row['Book']."<br>\n";}
mssql_close($sqlconnect);
?>

I keep gettign the error message:
Fatal error: Call to undefined function mssql_connect() in D:\web\cpt214-25\test.php on line 5

Now if im understanding this right php does not understand the command "mssql_connect".

Did I do something incorrect when installing php on the windows 2003 webserver? If so what do I need to do to correct it. I have read and done a couple things to try and figure this out but am at a loss.

I have installed the sql client tools on the webserver, edited the php.ini file and uncommented extension=php_mssql.dll in the Dynamic Extensions area. I have added to the path on the server both where php is installed and the ext directory within it. I have also enablee about everything I can network wise on the sql server, named pipes, etc. Nothing seems to be working for this. I also cannot find many resources for mssql connection strings or troubleshooting, mostly just mysql stuff.

I am tryign to get this working for a teacher and neither of us understand what is going on here. Any help would be appreciated. Any info that you may need, please just ask. These servers are completely internal so there is no way to give access to them. I setup the servers so Im trying to double check to make sure things are correct.

[Mod Edit - bpat1434] Added

 tags.
    1. No such thing as "Windows 2003 web server". Perhaps you mean Microsoft IIS6?

    2. Where did you place the php.ini file? I would recommend keeping everything centralized and placing it in c:\php\ .

    3. Have you created a PHPRC system environment variable to point to the directory where the php.ini file is stored (e.g. c:\php) ? If not, follow this FAQ to do so.

    4. You don't mention if you're using PHP4 or 5, so here 'goes. For both versions, you should add the PHP directory (e.g. c:\php) to your system PATH environment variable - instructions for doing so can be found in this FAQ. Now, if you're using PHP4, you also need to copy all of the files in the "dlls" folder into the main PHP folder (e.g. all files from c:\php\dlls\ moved to c:\php).

    5. Yes, after making both changes you must restart Windows - not just IIS.

      I think this is the same problem posted by your colleague

      The answer I gave there is that the manual copy of ntwdblib.dll into system32 means that it has not inherited the ntfs filesystem privileges associated with iis/php. In other words, IIS probably cannot execute it because IIS user is a low grade user with limited filesystem privileges. Try granting execute privileges to it for whatever the IIS user is (I forget myself). Also, make sure it is the required version, SQL2005 Client does not install one by default and the php version is wrong. Needs to be ver 8.x but which x you'll have to find out elsewhere. Try msdn for more info

        Roger Ramjet wrote:

        The answer I gave there is that the manual copy of ntwdblib.dll into system32 means that it has not inherited the ntfs filesystem privileges associated with iis/php.

        Precisely why no DLL files for PHP (or the php.ini file) should be moved outside the PHP folder (e.g. to a system folder) for any reason whatsoevever. Keeping all of the files in the c:\php\ folder makes it very simple to handle execute permissions for the IUSR_* account.

          Only trouble is that you have to in this situation apparently - unless MS are fooling everyone with their documentation.

            Thank you all for your help I finally got things working. The only thing I had not done was add a PHPRC system variable. Once that was cleared up and I was actually getting errorrs that were usefull I had more fun.

            I then had some auth issues. I found I had to add a iuser_machinename acount to the database server and set passwords for it on the web server and the db server. Then I had to add the iuser_machinename acount to the permissions for the database. I beleive the reason for this is becasue both of the servers are in the same domain. So any time they communicate with each other they are sending a security token. Well this token would override the sql auth login process and dissallow any of the sql accounts to login into the sql server. Atleast thats my theory anyways.

            The sql server was and still is set to mixed mode auth for sql. It was very odd becasue I could setup a DSN on the web server and could do the test from it fine there as well as go to any of the 100 or so workstations and use the sql management tools just fine as well. I managed webservers at an ISP about 6 years about, we had 5 sql servers and around 20 webservers and I never had a problem as strange as this. I thought jrun was fun to setup back then, but this takes the cake.

            After I got the auth issues figured out it was nothing more then getting the code to work. Again I want to thank you for your help everyone.

              Don't forget to mark this thread resolved.

              Roger Ramjet wrote:

              Only trouble is that you have to in this situation apparently

              Nah, never. It all has to do with: Did you add the PHP directory to your system's PATH environment variable (and reboot), and did you make sure all of the dlls are in that folder (e.g. move them from the 'dlls' folder on a PHP4 installation). That's the only thing special about placing files in the system32 folder - that folder is, by default, in the PATH variable. Adding the PHP directory to your PATH variable makes it just as special as the system32 directory.

                Write a Reply...