I can not make a simple conn between sql server and php !!
I have already downloaded and leave the ext folder the driver according to my version of php
I already mentioned them in php.ini I rebooted
And when I test the conn of this error below the code, someone knows how to solve it, unbelievable that microsoft can not do anything right a simple connection to the bank of their enormous torment.
$servidor = "MEU\SQLSERVER";
$basedatos = "novo";#
$usuario = "novo";#
$pass = "senha";
$info = array('Database' => $basedatos);
$conexion = sqlsrv_connect($servidor, $info);
if (!$conexion) {
die(print_r(sqlsrv_errors(), true));
}
echo 'Conectado';
error:
Array([0] => Array([0] => IMSSP[SQLSTATE] => IMSSP[1] => -49[code] => -49[2] => This extension requires the Microsoft ODBC Driver 11
for SQL Server.Access the following URL to download the ODBC Driver 11
for SQL Server
for x86: http: //go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Nome da fonte de dados não encontrado e nenhum driver padrão especificado [message] => [Microsoft][ODBC Driver Manager] Nome da fonte de dados não encontrado e nenhum driver padrão especificado ) )
I tried another code this locaweb is giving another error
$tabela = "nometabela"; #Nome da tabela
$campo1 = "campo1tabela"; #Nome do campo da tabela
$campo2 = "campo2tabela"; #Nome de outro campo da tabela
$conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password);
$conn = sqlsrv_connect($dbhost, $conninfo);
$instrucaoSQL = "SELECT $campo1, $campo2 FROM $tabela ORDER BY $campo1";
$params = array();
$options =array("Scrollable" => SQLSRV_CURSOR_KEYSET);
#ESSE DEU ERRO AQUI
$consulta = sqlsrv_query($conn, $instrucaoSQL, $params, $options);
$numRegistros = sqlsrv_num_rows($consulta);
echo "Esta tabela contém $numRegistros registros!\n<hr>\n";
if ($numRegistros!=0) {
while ($cadaLinha = sqlsrv_fetch_array($consulta, SQLSRV_FETCH_ASSOC)) {
echo "$cadaLinha[$campo1] - $cadaLinha[$campo2]\n<br>\n";
}
}