M
M
Matvey Kremnin2020-12-02 16:35:36
Drupal
Matvey Kremnin, 2020-12-02 16:35:36

How can I connect to a MS Sql database on Drupal 7 and work with it?

I faced such problem as connection to MS SQL.
The task is to pull certain fields from another database (MSSQL) and display them in the right place.
I created a module in which I allegedly connect to the desired database, the module does not work, it does not even turn on in the admin panel.
Prompt, direct.
Thank you.

<?php

$serverName = "test"; 
$connectionInfo = array( "Database"=>"dbtest", "UID"=>"qwer", "PWD"=>"1234");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question