Newbie question: I am connecting php to SQL Server for the first time. The connection has been established, using the sqlsrv_connect function.
I am now trying to return rows, but it returns this error:
Undefined index: Version in [FilePath] on line 62
<?php
$sql = "SELECT @@VERSION AS [version]";
$stmt = sqlsrv_query( $conn, $sql);
if($stmt === false) //if the query returns no rows
{
die(print_r(sqlsrv_errors(), true));
};
//echo the opening definition of the table in HTML5
echo "<table>
<tr>
<th>Version</th>
</tr>";
//echo the rows returned
while( $row = sqlsrv_fetch_Array($stmt, SQLSRV_FETCH_ASSOC) )
{
echo "<tr>";
echo "<td>".$row['Version']."</td>" ; //<<- This is line 62
echo "</tr>";
}
//close the table tag
echo "</table>";
?>
I expect this is such a newb question, and I am missing something really obvious. I'm not a PHP coder, as you can probably imagine.
Update: Appreciated that this question is related to the answer in another question, but really, my question is definitely different, because the solution was different. The solution here has to do with the case of the characters in the code.