sql error with php

0

I want to connect sql server with php, I have the following error:

  

****** Connection could not be established. Array ([0] => Array ([0] => 08001 [SQLSTATE] => 08001 [1] = > 2 [code] = > 2 [2] = & [[Microsoft] [ODBC   Driver 11 for SQL Server] Named Pipes Provider: Could not open a   connection to SQL Server [2]. [message] = > [Microsoft] [ODBC Driver 11   for SQL Server] Named Pipes Provider: Could not open a connection to   SQL Server [2]. ) [1] = > Array ([0] => HYT00 [SQLSTATE] => HYT00 [1]   = > 0 [code] = > 0 [2] = > [Microsoft] [ODBC Driver 11 for SQL Server] Login timeout expired [message] = > [Microsoft] [ODBC Driver 11   for SQL Server] Login timeout expired) [2] = > Array ([0] => 08001   [SQLSTATE] = > 08001 [1] = > 2 [code] = > 2 [2] = > [Microsoft] [ODBC   Driver 11 for SQL Server] A network-related or instance-specific error   have occurred while establishing a connection to SQL Server. Server is   not found or not accessible Check if instance name is correct and if   SQL Server is configured to allow remote connections. For more   information see SQL Server Books Online. [message] = > [Microsoft] [ODBC   Driver 11 for SQL Server] A network-related or instance-specific error   have occurred while establishing a connection to SQL Server. Server is   not found or not accessible Check if instance name is correct and if   SQL Server is configured to allow remote connections. For more   information see SQL Server Books Online. )) ******

now download the ODBC, and configure the php.ini, this is my code:

<?php
$serverName = "localhost"; //serverName\instanceName
$connectionInfo = array( "Database"=>"prueba", "UID"=>"JhonaJM", "PWD"=>"Inicio.123");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Conexión establecida.<br />";
}else{
     echo "Conexión no se pudo establecer.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

I hope you can help me, thanks in advance.

    
asked by Jhona JM 27.10.2018 в 01:10
source

0 answers