NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP and MSSQL 7

Nestor Florez nestorflorez at earthlink.net
Mon Dec 20 15:56:40 EST 2004


Joe,


This is what I use when accessing a Mssql DB

$hostname = "192.168.0.20,1433";
$username = "user1";
$password = "pwd1";
$dbName   = "mydb";


if($conn = mssql_connect($hostname,$username,$password))
{
}
else
{
  die("DATABASE FAILED TO RESPOND.");
}

Hope that this helps you.

Nestor :-)
http://www.IneedWork.org
-----Original Message-----
From: Joseph Crawford <codebowl at gmail.com>
Sent: Dec 20, 2004 11:55 AM
To: NYPHP Talk <talk at lists.nyphp.org>
Subject: [nycphp-talk] PHP and MSSQL 7

Hello Everyone,

i have been trying to use the MSSQL functions in PHP and i cannot get
it to connect i keep getting the error that mssql_connect cannot
connect to the host.

$link = mssql_connect("207.76.168.21", $dbinfo['user'], $dbinfo['pass']);

that is the connection string i was using
and this is the error recieved

Warning: mssql_connect(): Unable to connect to server: 207.76.168.21
in /htdocs/data.php on line 9

I read the docs and noticed a user comment about using freetds, i$link
= mssql_connect("207.76.168.21", $dbinfo['user'], $dbinfo['pass']);
added a server to my freetds.conf file which was found in /etc/ and
then i restarted apache, i changed my mssql_connect to look like this

$link = mssql_connect("MyServer70", $dbinfo['user'], $dbinfo['pass']);

when i use this, i get the same error except the hostname is now
MyServer70 rather than the IP address of the server, here is what i
have in my freetds config

# A typical Microsoft SQL Server 7.0 configuration	
[MyServer70]
	host = 207.76.168.21
	port = 1433
	tds version = 7.0

after adding that i restarted my xampp apache install and i get this error

Warning: mssql_connect(): Unable to connect to server: MyServer70 in
/htdocs/data.php on line 9

am i doing something wrong or is this generally hard to accomplish
from a linux to windows server connection?

-- 
Joseph Crawford Jr.
Codebowl Solutions
codebowl at gmail.com
_______________________________________________
New York PHP Talk
Supporting AMP Technology (Apache/MySQL/PHP)
http://lists.nyphp.org/mailman/listinfo/talk
http://www.newyorkphp.org






More information about the talk mailing list