Reputation: 341
I want to execute a simple sqlsrv_query query in php. To do so, I installed the MS Drivers and was able to establish a connection to my DB (SQL Server Management Studio 18.9.2). What I don´t understand is the message Resource id #3
, which I believe is neither an failure or error. I expect a raw echo / print_r of the table content. What do I miss?
$sql = "SELECT * FROM nodes";
$stmt = sqlsrv_query($conn, $sql);
if ($stmt === false) {
die (print_r(sqlsrv_errors(), true));
} else {
while ($row = sqlsrv_fetch($stmt))
print_r($row);
print_r($stmt);
echo "<br />Statement executed";
}
The table looks like:
Error I get:
Upvotes: 0
Views: 41
Reputation: 1319
Try to use sqlsrv_fetch_array statement instead of the sqlsrv_fetch.
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
{
// print_r($row);
print($row["nodes"] . "<br>");
}
Upvotes: 1