I am trying to connect and select all fields on the Sales Invoice Header table and echo only the 'No_' field. I am using php with the sqlsrv extension. When I run it I get this error:
Array ( [0] => Array ( [0] => 42S02 [SQLSTATE] => 42S02 [1] => 208 [code] => 208 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name 'CRONUS Ísland hf_$Sales Invoice Header'. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name 'CRONUS Ísland hf_$Sales Invoice Header'. ) )
but the table name is spelled correctly.
here is my code:
<?php
$serverName = 'SP-101';
$connectionInfo=array('Database'=>'Demo Database NAV (7-1)');
$conn = sqlsrv_connect ($serverName, $connectionInfo);
if($conn == TRUE) {
echo 'Connected';
}else{
echo 'Connection failed<br />';
die(print_r(sqlsrv_errors (), TRUE));
}
$sql = 'SELECT * FROM "CRONUS Ísland hf_$Sales Invoice Header"';
$stmt = sqlsrv_query($conn, $sql);
if($stmt == false){
die(print_r(sqlsrv_errors(), TRUE));
}
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
$no = 'No_';
echo $row[$no];
}
?>