RE: PHP Runs But Does NOT Connect to MSSQL Server

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

 



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
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei@xxxxxxxxxxx
________________________________________
From: Greg Maruszeczka [listmail@xxxxxxxxxx]
Sent: Friday, June 13, 2008 10:51 AM
To: php-general@xxxxxxxxxxxxx
Subject: Re:  PHP Runs But Does NOT Connect to MSSQL Server

On Fri, 13 Jun 2008 10:32:22 -0400
"Wei, Alice J." <ajwei@xxxxxxxxxxx> wrote:

> Hi, Greg:
>
>   I have just run the command
>
> [root@localhost php-5.2.6]# php -m | grep mssql
> mssql
>
> It appears that my RPM is fully installed. I could ping to the
> machine, but I could not connect to it. I have set the TCP to 1433,
> and UDP to 1434. Therefore, even though my syntax
>
> $dbhandle= mssql_connect($myServer, $myUser, $myPass)
>
> appears to be accurate with the proper password, ip, and username
> defined prior to this, I only get "PHP Warning:  mssql_connect():
> Unable to connect to server:  192.168.10.128
> in /usr/local/apache/htdocs/test.php on line 22" Could there be
> something that I have missed?
>

Alice

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?

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