In a connection from PHP to SQL server I have the following error:
sqlsrv_fetch_array () expects parameter 1 to be resource string given
This is the code:
$server = "SQLSERVER\INSTANCIAALABD";
$conn = array("Database" => "NOMBREDATABASE", "UID" => "NAME", "PWD" => "NAMEPWD");
$con = sqlsrv_connect($server, $conn);
if($con){
echo "conectado";
} else {
echo "desconectado";
}
$tsql = "select NOMBRE from CIUDAD";
$getciudad = sqlsrv_query($con, $tsql);
if($getciudad = FALSE) die(FormatErrors(sqlsrv_errors()));
while($row = sqlsrv_fetch_array($getciudad, SQLSRV_FETCH_ASSOC)){
echo $row['NOMBRE'];
echo "<br/>";
}