RE: PHP Runs But Does NOT Connect to MSSQL Server

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

 



> -----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!");

The hostname and port are separated by a comma, as mentioned in the PHP
reference page I have linked to. Give it a shot, and see if it helps at
all.

If not, sorry... but it was worth a try, eh? ;)


Todd Boyd
Web Programmer




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