我想從SQL數據庫從Azure解析數據到使用PHP的JSON。我有一個免費的網絡託管服務器上的PHP腳本。當我連接到Azure的SQL數據庫時,我收到了一個錯誤。PHP的MSSQL數據庫Azure
我的PHP腳本
<?php
$serverName = "tcp:ss4rda587x.database.windows.net,1433";
$connectionOptions = array("Database"=>"DistribuireColete",
"Uid"=>"[email protected]", "PWD"=>"******");
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
//Select Query
$tsql = "SELECT * FROM Clienti";
//Executes the query
$getProducts = sqlsrv_query($conn, $tsql);
if (!$getProducts)
{
//Query failed
echo("Nu merge");
}
else
{
$clienti = array(); //Create an array to hold all of the contacts
//Query successful, begin putting each contact into an array of contacts
while ($row = sqlsrv_fetch_array($stmt,SQLSRV_FETCH_ASSOC)) //While there are still contacts
{
//Create an associative array to hold the current contact
//the names must match exactly the property names in the contact class in our C# code.
$client = array("ID" => $row['IdClient'],
"Name" => $row['NumeClient'],
"Number" => $row['TelNumar'],
"ImageBase64" => base64_encode($row['Icon'])
);
//Add the contact to the contacts array
array_push($clienti, $client);
}
//Echo out the contacts array in JSON format
echo json_encode($clienti);
}
?>
和錯誤我收到
Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in H:\root\home\cdan26-001\www\site1\GetClienti.php on line 14