Reputation: 91
I'm trying to query a datasource using a simple SQL query, but I'm getting the following error: *Warning: odbc_exec() [function.odbc-exec]: SQL error: [SimbaLNA][Simba][SimbaEngine ODBC Driver]select (<< ??? >>[agent_id], [agent_name]) from agent;, SQL state 37000 in SQLExecDirect in C:\xampp\htdocs\Tas\showtables.php on line 22*
I know my ODBC connection is established and connecting correctly because I'm able to execute the following code and receive a list of all the table names.:
if (!$conn) {
{exit("Connection Failed: " . $conn);}
}
$result = odbc_tables($conn);
$tables = array();
while (odbc_fetch_row($result)){
if(odbc_result($result,"TABLE_TYPE")=="TABLE") {
echo"<br>".odbc_result($result,"TABLE_NAME");
}//end if
}//end while
When I proceed and try and execute the below code:
/* Fetch The Fieldnames into an Array */
if($result = odbc_exec($conn,"SELECT agent_id, agent_name FROM agent")) {
for($i = 1;$i <= odbc_num_fields($result);$i++) {
$odbc['rows']['fields'][$i] = odbc_field_name($result,$i);
} //end for
unset($i);
odbc_free_result($result);
}//end if
else {
exit("Error in SQL Query");
}//end else
I get the error stated above. Does anyone know why this would be happening?
If any more information is required, just let me know.
Many thanks in advance
Upvotes: 0
Views: 687