forked from Azure-Samples/php-docs-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbconnecttest.php
23 lines (23 loc) · 921 Bytes
/
dbconnecttest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$serverName = "jdlfa-server.database.windows.net,1433"; // update me
$connectionOptions = array(
"Database" => "jdlfa-database", // update me
"Uid" => "jdlfa-server-admin", // update me
"PWD" => "Fe3Mo0R5imp!" // update me
);
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
$tsql= "SELECT * from jfwatab1 ORDER BY 'founddate' ";
$getResults= sqlsrv_query($conn, $tsql);
echo ("Reading data from table" . PHP_EOL);
if ($getResults == FALSE) {
echo (sqlsrv_errors());
} else {
echo "We are lacking something but not erroring out on the database connection";
}
echo $getResults;
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
echo ($row['invtagid'] . " " . $row['lostitemtype'] . " " . $row['founddate'] . PHP_EOL);
}
sqlsrv_free_stmt($getResults);
?>