unable to connect server 2005 on localhost have sp2

  • I've setup the database, setup the server. I get to my website which takes me to index.php, executes, but when I get to the code:

    $msconnect=mssql_connect('127.0.0.1', 'databasename', database-password');

    I get

    Warning: mssql_connect(): Unable to connect to server: 127.0.0.1 in C:\debwebroot\CabrilloDJD\Index2.php on line 8

    I can ping 127.0.0.1, I clearly am getting to my website or I wouldn't be executing the index.php code.

    I have this same basic setup on another machine but that machine runs server Express and not server 2005. I've followed some of the instructions I've seen about the firewall stuff, even turned off the darned firewall but no joy.

    I'm just trying to run a local website for testing PHP code. I don't even want the code on the actual internet for others to see.

    deb.sites@sbcglobal.net

  • The parameters for mssql_connect are server, username, password.  This means you are using SQL security, so SQL Server must be in mixed mode (the default is Windows Authentication only).  Are you passing a database name instead of a user id such as sa ?  After connecting, you woud use mssql_select_db() to perform the equivalent of USE <database>.

     

  • Thanks for your suggestion of looking for mixed mode. I still am not seeing that as an option somewhere.

    I rechecked login and password - they are what shows up in my server as one of the login options. It has permission to open the database.

    I have two machines. Both run windows xp pro and server express. The server works on my old machine. I don’t actually have a website on www as I do not have a static ISP. I am simply running tests in a loopback mode (use localhost) on the PHP programs I develop for the company that hosts them. The machine which works was setup by someone else. My guess is I just don’t adequately know how to setup the server.

    I can’t seem to setup the server to be recognized on the new machine. The versions of Microsoft server must differ slightly because the interface is just a tiny bit different. The new machine DOES recognize the website- it executes the php code correctly and displays, but fails when I get to

    $msconnect=mssql_connect('127.0.0.1', ‘CabrilloUserLogin’, ‘DJDallowAccess’);

    I get Unable to connect to server: 127.0.0.1 … I get a different message ‘Login fails for bad user’ if I just have the wrong userlogin on password (I forced working machine to use ‘bad user’ as the login name). So I know from this that the server isn’t even setup enough to check the user name, password.

    _ Basically, here is what I have

    Old machine: works

    Administrative Tools

    Computer Management

    Services and Applications

    Microsoft SQL Servers

    (local)(Windows NT)

    DEBDOLSPC\SQLEXPRESS – I DON’T HAVE THIS ON NEW MACHINE

    (local) shows Security tab as SQLServer and Windows authentication, startup service account is system account. (local) also shows up under Microsoft SQL Servers, SQL Server Group DEBDOLSPC\SQLEXPRESS does not. I note that if I stop or pause THIS SQL Server, I get unable to connect or server paused, so I am assuming that the sql server used to get at my localhost is this one.

    The DEBDOLSPC\SQLEXPRESS has Use windows authentication, with Server Group:Microsoft SQL Servers, and automatically start SQL Server when connecting

    New machine: doesn’t work

    The Administrative Tools looks a little different:

    Administrative Tools

    Computer Management

    Services and Applications

    SQL Server Configuration

    SQL Server 2005 Services

    SQL Server (SQL Express)

    This looks a bit different though . I’ve tried all three Logon AS options: Local system, Local Service, Network Service. I suspect I just want Local System since I only want to use this particular machine to run the website.

    I suspect i just don't know quite how to setup the server for use just on my own machine in loopback

    I've looked online but haven't seen instructions for setting up such a simple system. Any help appreciated.

  • Run REGEDIT.EXE and look for this registry key:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer

    One of the values in the pane on the right side should be LoginMode.

    1 means Windows Authentication only, 2 means Mixed mode

    Change it to 2, then exit RegEdit.  Restart SQL Server 2005 Express.

     

  • Another issue might be that in SQL Server Express, TCP/IP is disabled by default. 

    1. Run the SQL Server Configuration Manager

    2. Expand SQL Server 2005 Network Configuration

    3. Click on Protocols for SQLEXPRESS

    4. Look in the right-hand pane for TCP/IP - it should be enabled.

    5. To enable, right on TCP/IP and select Enable from the popup menu.

  • Thanks for the tips. I had already read online about setting up TCP/IP and had it enabled. I set the login mode to 2 (mixed), but only saw a loginMode option on my MSSQL.4 entry. There was no MSSQL.1 in my list.

    Any other ideas?

  • Have you reinstalled SQL Server Express, or do you have multiple instances? I would change the entry for MSSQL.4. You have to restart the server for it to take effect.  [edit: re-reading your response, I see you already did that]

    Another thing to notice is that SQL Server Express installs as a named instance, so it looks like you need to specify machine name\SQLEXPRESS as the server name. Using an IP address as an example of the machine name:

    172.0.0.1\SQLEXPRESS

  • One more thing, if you still can't connect, go to Control Panel | Administrative Tools | Services and start the SQL Server Browser service. Try to connect again. If you can connect after starting the service, change the service startup type to Automatic.

    I used the machines actual IP address to test this, not the loopback address (127.0.0.1), but that should work as well.

  • still no joy. I used several permutations of localhost\sqlexpress as the server name including

    127.0.0.1\SQLEXPRESS

    Deb-5150\SQLEXPRESS

    (isp number from ipconfig /all)\SQLEXPRESS

    and all of the above without the \SQLEXPRESS.

    Also, I installed SQL from an SQL SERVER 2005 Standard system, but I still only see the sqlexpress stuff in the services.

    I've uninstalled and reinstalled once, and now I have all the way to MSSQL.4.

    I'm considering uninstalling, then getting rid of stuff by hand to "clean things out" then reinstall. Do you think there is a point to that?

    I don't really need full sql server. express would be fine. Should I download to get clean copy and try installing that?

  • AFter much hair pulling, I tried uninstall reinstall - no joy. Finally reinstalled ALL software including OS and installing 2005 EXPRESS without an attempt at loading my full sql server 2005 and I got connection with the database. i did indeed need to name the instance deb-5150\SQLEXPRESS unlike my former full version of server 2000 which let me simply give the 127.0.0.1 local host designation. This difference is documented in the bowels of the server 2005 express installation instructions.

    Anyway, thanks to those who tried to help. I have no idea what bad thing happened on the way to installing it and trying to use it before.

    debra

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply