First day with SQL Server Driver for PHP...
I'm checking the result of the call to sqlsrv_connect() so I can throw an exception in my code. I enter wrong credentials and I call to sqlsrv_errors() to get the error message. Curiously, I always get the same error messages twice. E.g., a wrong password:
I'm checking the result of the call to sqlsrv_connect() so I can throw an exception in my code. I enter wrong credentials and I call to sqlsrv_errors() to get the error message. Curiously, I always get the same error messages twice. E.g., a wrong password:
ArrayNow wrong database:
(
[0] => Array
(
[0] => 28000
[SQLSTATE] => 28000
[1] => 18456
[code] => 18456
[2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Error de inicio de sesión del usuario 'sa'.
[message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Error de inicio de sesión del usuario 'sa'.
)
[1] => Array
(
[0] => 28000
[SQLSTATE] => 28000
[1] => 18456
[code] => 18456
[2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Error de inicio de sesión del usuario 'sa'.
[message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Error de inicio de sesión del usuario 'sa'.
)
)
Array
(
[0] => Array
(
[0] => 28000
[SQLSTATE] => 28000
[1] => 18456
[code] => 18456
[2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Error de inicio de sesión del usuario 'sa'.
[message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Error de inicio de sesión del usuario 'sa'.
)
[1] => Array
(
[0] => 42000
[SQLSTATE] => 42000
[1] => 4060
[code] => 4060
[2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]No se puede abrir la base de datos "xxxICCL_ITCWEB_WEB" solicitada por el inicio de sesión. Error de inicio de sesión.
[message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]No se puede abrir la base de datos "xxxICCL_ITCWEB_WEB" solicitada por el inicio de sesión. Error de inicio de sesión.
)
[2] => Array
(
[0] => 28000
[SQLSTATE] => 28000
[1] => 18456
[code] => 18456
[2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Error de inicio de sesión del usuario 'sa'.
[message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Error de inicio de sesión del usuario 'sa'.
)
[3] => Array
(
[0] => 42000
[SQLSTATE] => 42000
[1] => 4060
[code] => 4060
[2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]No se puede abrir la base de datos "xxxICCL_ITCWEB_WEB" solicitada por el inicio de sesión. Error de inicio de sesión.
[message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]No se puede abrir la base de datos "xxxICCL_ITCWEB_WEB" solicitada por el inicio de sesión. Error de inicio de sesión.
)
)
My code is pretty straightforward:<?php
$conn = sqlsrv_connect('server\\instance', array(
'UID' => 'user',
'PWD' => 'password',
'Database' => 'database',
));
if( !$conn ){
$e = sqlsrv_errors();
print_r($);
}
?>
Why do they show up twice?