Re: PHP Runs But Does NOT Connect to MSSQL Server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 13 Jun 2008 10:41:54 -0500
"Boyd, Todd M." <tmboyd1@xxxxxxxx> wrote:

> > -----Original Message-----
> > From: Wei, Alice J. [mailto:ajwei@xxxxxxxxxxx]
> > Sent: Friday, June 13, 2008 10:25 AM
> > To: Greg Maruszeczka; php-general@xxxxxxxxxxxxx
> > Subject: RE:  PHP Runs But Does NOT Connect to MSSQL Server
> > 
> > Hi, Greg:
> > 
> >  i have went back to the conf file I have in the freetds directory
> > to edit the server information to
> > 
> > # A typical Microsoft server
> > [egServer70]
> >         host = 192.168.10.128
> >         port = 1433
> >         tds version = 7.2
> > 
> > Since I am using MS SQL 2005, I thought I would have to change this
> > to tds version 7.2 instead of 7.0.
> > I have edited the MSSQL connection to as follows:
> > 
> > //connection to the database
> > $dbhandle = mssql_connect($myServer, $myUser, $myPass)
> >   or die("Couldn't connect to SQL Server on $myServer");
> > 
> > //select a database to work with
> > $selected = mssql_select_db($myDB, $dbhandle)
> >   or die("Couldn't open database $myDB");
> > 
> > Since I could not find the exact syntax for this on
> http://www.php.net,
> > I have modified it as you suggested. The error message that says
> > couldn't connect to the server was brought back a lot quicker than
> > before, but I still could not connect it.
> > 
> > Are there other packages I have to install?
> > Thanks for your help.
> > 
> > Alice
> 
> ---8<--- snip
> 
> > From: Greg Maruszeczka [listmail@xxxxxxxxxx]
> > Perhaps. Check the documentation for myssql_connect and be sure that
> > you're not supposed to also provide a port number (in your case
> > 1433) along with the hostname argument. IIRC you can tag it after
> > the hostname/ip using a colon (e.g. myhostname:1433).
> > 
> > Other than that it seems more like a network connectivity issue.
> > This is OT for this list but if it was my problem I'd ensure there
> > aren't any packet filters between my web server and db hosts. Since
> > MSSql has to run on windows I'd start there and ensure inbound
> > connects to TCP 1433 are allowed. You're using private address
> > space (192.168.x.x).
> Are
> > BOTH servers on the same subnet?
> 
> Alice,
> 
> You still have not tried to connect to your MS SQL server using your
> supplied port number in your code above. A quick glance at
> http://us.php.net/mssql_connect shows that a port number can, in fact,
> be passed in the "hostname" parameter. For instance:
> 
> $dbhandle = mssql_connect($myServer . "," . $myPort, $myUser, $myPass)
> or die("Uh-oh!");



Alice:

Oops...it seems Todd is correct. Sorry for misleading you with the port
number syntax, I should have mentioned along with the 'IIRC' that I
don't *always* recall things correctly :) Documentation is my best
friend and it should be yours as well.

It seems pretty obvious but can you confirm that MSSQL is actually
running on 192.168.10.128 and listening on the port you think it is? Try
'netstat -an' from what passes for a command line on the windows host
and make sure TCP 1433 is bound to that address (and not just
127.0.0.1). Then check that windows isn't blocking that port using
whatever it has for a 'firewall'.

However, none of this concerns PHP per se so I won't be replying
again in this thread unless that changes. If you still have troubles
I suggest you consider bribing your friendly-neighbourhood system or
network administrator with a good cup of coffee and a donut in order to
troubleshoot further.

GM

-- 
   
Greg Maruszeczka

http://websagesolutions.com
skype: websage.ca
googletalk: gmarus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux