Php MSSQL(2012) giving error:Couldn’t connect to SQL Server -
i trying fetch set of fields database on mssql database on sql server 2012. remote server , trying following piece of code.
//mssql server retrieving member name member id: //mssql.secure_connection = on // need upload ntwdblib.dll net $myserver = "ipaddress/sqlexpress "; // host/instance_name $myuser = "id"; // username $mypass = "pass"; // paasword $mydb = "dbname"; // database name // connection database $dbhandle = mssql_connect($myserver, $myuser,$mypass) or die("couldn’t connect sql server on $myserver"). mssql_get_last_message(); // select database work $selected = mssql_select_db("sportsclub", $dbhandle) or die("couldn’t open database $mydb"); echo "you connected " . $mydb . " database on " . $myserver . "."; $query = "select first_name, last_name"; $query .= "from members "; $query .= "where member_id='".$row['member_id']."'"; // database query $result = mssql_query($query); while($row = mssql_fetch_assoc($result)) { echo "<td>" . $rows["first_name"] . $rows["last_name"] . "</td>"; } // close connection mssql_close($dbhandle); //ended mssql connection
it not connect sql server. gives error: couldn’t connect sql server on ipaddress/sqlexpress
i tried checking configurations tcp/ip through sql server config management.
can please help?
ensure remote connections on named pipes enabled , make sure you're using backslash before instance name:
$myserver = "ipaddress\sqlexpress ";
if you'd enable connection on default port (1433) answer help.
Comments
Post a Comment