microsoft sql server connection and configuration in php

1

I'm trying to connect to a microsoft sql server database using php. The php version is:

PHP Version 5.6.3

and the error it gives is

  

Fatal error: Call to undefined function mssql_connect () in C: \ xampp \ htdocs \ aloha.php on line 7 **

I tried to use the command:

<?php  
$myServer = "server";
$myUser = "user";
$myPass = "senha";
$myDB = "mydb";

$conn = mssql_connect($myServer,$myUser,$myPass);
if (!$conn)
{ 
die('Not connected : ' . mssql_get_last_message());
} 
$db_selected = mssql_select_db($myDB, $conn);
if (!$db_selected) 
{
die ('Can\'t use db : ' . mssql_get_last_message());
} 
?>  

I went into php.ini and uncommented the

extension=php_mssql.dll

but it still did not work.

The phpinfo data I found to be too large to post here, so if you need any specific data ask here.

    
asked by anonymous 02.12.2015 / 14:34

1 answer

2

documentation informs you that this extension is no longer available since php5.3. The recommendation is to use other APIs such as PDO or sqlsrv .

  

This extension is not available anymore on Windows with PHP 5.3 or later.

Example with sqlsrv:

<?php
$servidor = 'ip ou servidor\instancia';
$db = 'test';
$usuario = 'user';
$senha = 'pass';        

$conexao = sqlsrv_connect($servidor, array('Database' => $db, 'UID' => $usuario, 'PWD' => $senha));

Related:

PDO Drivers for SQL Server

SQLSRV Documentation

    
02.12.2015 / 14:42