Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This topic describes how to connect to SQL Server on a specified port with the Microsoft Drivers for PHP for SQL Server.
To connect on a specified port
Verify the port on which the server is configured to accept connections. For information about configuring a server to accept connections on a specified port, see How to: Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager).
Add the desired port to the $serverName parameter of the sqlsrv_connect function. Separate the server name and the port with a comma. For example, the following lines of code use the SQLSRV driver to demonstrate how to connect to a server named myServer on port 1521:
$serverName = "myServer, 1521"; sqlsrv_connect( $serverName );
The following lines of code use the PDO_SQLSRV driver to demonstrate how to connect to a server named myServer on port 1521:
$serverName = "(local), 1521"; $database = "AdventureWorks"; $conn = new PDO( "sqlsrv:server=$serverName;Database=$database", "", "");
See Also
Programming Guide for the Microsoft Drivers for PHP for SQL Server
Getting Started with the Microsoft Drivers for PHP for SQL Server