Skip to Content.
Sympa Menu

freetds - Re: [freetds] Connecting MSSQL Server from Red Hat linux + PHP

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Arnar Birgisson" <ArnarB AT oddi.is>
  • To: <mlmsrini AT lycos.com>
  • Cc: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] Connecting MSSQL Server from Red Hat linux + PHP
  • Date: Thu, 03 Jul 2003 08:17:15 +0000

Hi Svan

As James clarified earlier, /usr/local/etc/freetds.conf is the one to use.

1433 is the default port, so I don't think that's needed, try
mssql_connect("192.168.4.25",...). I installed the snapshot from two days ago
and I'm having some problems connecting to servers with no freetds.conf entry
myself since then, has this been changed in any way (I suspect iconv is
pulling my chain though)?

Here's my entry in freetds.conf, and my connection routine.. compare this to
yours:

[stmdatabase]
host = vegas.oddi.is
port = 1433
tds version = 8.0


// from the php files

$config["database_host"] = "stmdatabase";
$config["database_db"] = "starfsmannakerfi";

function connect($username, $passwd) {
global $config;
if ($this->connected) die("Already connected!");
$this->user = $username;
$this->password = base64_encode($passwd);
$this->_conn = mssql_connect($config["database_host"],
"stmkerfi_".$username, $passwd);
if (!$this->_conn) {
return false;
} else {
$this->connected = true;
if (!mssql_select_db($config["database_db"], $this->_conn))
die("Gat ekki valið gagnagrunn í DB::connect");
return true;
}
}

If these don't help, put this line at the top of your script:
putenv("TDSDUMP=/tmp/tdsdump");

then run the script and look at /tmp/tdsdump in a text editor. If you don't
get some ideas from that, send it to us, removing any confidential
information.

Arnar


>>> "Venkatraman M Srinivasan" <mlmsrini AT lycos.com> 2.7.2003 22:16:46 >>>
Hi
I have installed php-4.3.2 and compiled --with-mssql=/usr/local.
No errors occured during compilation. Now i am getting the mssql support
description for the first time in the phpinfo list.

Then i tried with the sample php code.
<?
// connectivity test
$conn = mssql_connect("MYSERVER70",$user,$pswd)
or die( "Connection to MSSQL SERVER failed" );
// Also i 've tried this
$conn = mssql_connect("192.168.4.25:1433",$user,$pswd)
// Then tried with this - For SQL Server 2000 we have to use , instead of :
for the port number - some suggest this
$conn = mssql_connect("192.168.4.25,1433",$user,$pswd)

$query = mssql_query("SELECT product_name from product",$conn);
while ($row=mssql_fetch_array($query)) {
$prodName=$row["product_name"];
echo ("Product - ".$prodName."<br>");
}
?>
Now i am getting the error
'Warning: mssql_connect(): Unable to connect to server: MYSERVER70 in
/home/httpd/test/test.php on line 4'
ERROR: Connection to MSSQL SERVER failed
It's throwing the die part.

(Previously i was getting the error 'Fatal error: Call to undefined
>>>function: mssql_connect() in /home/httpd/test/test.php on line 4'.)

This means now it is working for mssql extensions.
But now the problem is with the MSSQL Server connectivity.

I have specified this in freetds.conf file which is inside /usr/local/etc.
[MYSERVER70]
host = 192.168.4.25 // MSSQL Server's IP
port = 1433
tds version = 7.0
Also i have got the same file freetds.conf inside my /usr/local/freetds/
folder. I have specified the above server specification in this file aswell.
I don't know which one to use.
Is the problem because of this?. If so can i delete one freetds.conf file
which is not needed.
So in general it seems i am very close to achieve the MSSSQL Server
connectivity.

Any suggestions?

Thanks

svan



____________________________________________________________
Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page