Reputation: 61
I have a ton of experience connecting to MySQL, but I'm attempting to connect to a SQL Server for the first time.
I've been given an IP address, server name, and a port. I've tried every combination I can think of for the server string to make the connection, but nothing appears to be working:
"127.0.0.1:1443\servername"
"127.0.0.1,1443\servername"
"servername\127.0.0.1:1443"
"servername\127.0.0.1,1443"
etc...
All fail.
I guess I'm asking for the correct formatting of the server parameter string to connect to MS SQL from a php script.
$ip = '127.0.0.1';
$port = '1433';
$server_name = 'servername';
$server = "$ip,$port\servername"; // <-- this is the line I need help with
$username = 'user';
$password = 'pass';
$con = mssql_connect($server, $username, $password)
or die('Could not connect to the server!');
Thanks in advance!
Upvotes: 0
Views: 6017
Reputation: 3720
$ip = '127.0.0.1';
$port = '1433';
$server_name = 'servername';
$server = "$ip.":".$port";
$username = 'user';
$password = 'pass';
$con = mssql_connect($server, $username, $password)
or die('Could not connect to the server!');
This should work
Upvotes: 1
Reputation: 4631
if you are using linux
$con = mssql_connect($server_name.":".$port,$username,$password);
or on windows
$con = mssql_connect($server_name.",".$port,$username,$password);
to connect mssql server
Upvotes: 2