RE: PHP Runs But Does NOT Connect to MSSQL Server

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

 



Hi, Greg:

  One of the members on the list advised me to use telnet to see if this is working. I have fixed up my errors so that it now gives me this:

Connected to 192.168.10.68.
Escape character is '^]'.

This appears to signify that I can now actually connect to the actual server, while I cannot actually connect to the "MS SQL" through the PHP.
 What I am confused about is that when I was compiling freetds into my PHP  installation, I used this as my configuration option:

./configure --with-mssql=/usr/local/freetds --prefix=/usr/local/php

  I get this in my last few lines of my installation before I started to make the file.

  checking for MSSQL support via FreeTDS... yes
  configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory

  Is this one of the reasons why I am having issues getting connected? If yes, are there other options to solve it as my application is running on Linux?

Thanks again for your help.

======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei@xxxxxxxxxxx
________________________________________
From: Greg Maruszeczka [greg@xxxxxxxxxx]
Sent: Friday, June 13, 2008 12:31 PM
To: php-general@xxxxxxxxxxxxx
Subject: Re:  PHP Runs But Does NOT Connect to MSSQL Server

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


-- 
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