2

Below are my code :

  $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>";

Below is my error:

  1. SQLSTATE: 42S22
  2. code: 207
  3. message: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid column name 'group_id'.

SQLSTATE: 42S22 code: 207 message: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid column name 'type'.

below are link to screenshot of my database; enter image description here enter image description here

As you can see.It says that invalid column.But i pretty sure the column name is same as in my sql server.i do not know what is wrong,can somebody help me.

Community
  • 1
  • 1

0 Answers0