Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $serverName = "IP OF MY SERVER";
- $connectionOptions = array(
- "Database" => "DB NAME",
- "Uid" => "USER",
- "PWD" => "PASSWORD"
- );
- //Establishes the connection
- $conn = sqlsrv_connect($serverName, $connectionOptions);
- //Select Query
- $tsql = "SELECT @@Version as SQL_VERSION";
- //Executes the query
- $getResults = sqlsrv_query($conn, $tsql);
- //Error handling
- if ($getResults == FALSE)
- die(FormatErrors(sqlsrv_errors()));
- sqlsrv_free_stmt($getResults);
- function FormatErrors($errors) {
- /* Display errors. */
- /* echo "Errors: <br/>";
- foreach ($errors as $error) {
- echo "SQLSTATE: " . $error['SQLSTATE'] . "<br/>";
- echo "Code: " . $error['code'] . "<br/>";
- echo "Message: " . $error['message'] . "<br/>";
- }
- }
Add Comment
Please, Sign In to add comment