以下是我的代码:
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
$sql = 'SELECT [group_id],[type] FROM Users';
$stmt = sqlsrv_query($conn,$sql);
if($stmt == false)
{
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
echo "
<table>
<tr>
<th>fname</th>
<th></th>
</tr>";
while ($row=sqlsrv_fetch_Array($stmt,SQLSRV_FETCH_ASSOC))
{
echo "<tr>";
//echo "<td>".$row['users_id']."</td>";
echo "<td>".$row['group_id']."</td>";
echo "<td>".$row['type']."</td>";
//echo "<td>".$row['fname']."</td>";
//echo "<td>".$row['reg_date']."</td>";
//echo "<td>".$row['contact']."</td>";
//echo "<td>".$row['line1'].$row['line2']."</td>";
echo "</tr>";
}
echo"</table>";
SQLSTATE:42S22 代码:207 消息:[Microsoft] [用于SQL Server的ODBC驱动程序17] [SQL Server]无效的列名称'type'。
下面是我的数据库截图的链接; 在此输入图像描述 enter image description here
正如你所看到的那样。它说无效的列。但我非常确定列名与我的sql server中的相同。我不知道有什么问题,有人可以帮助我。