English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The odbc_errormsg() function retrieves the last error message.
string odbc_errormsg ([ resource $connection_id ] )
It is used to get the last error message
If connection_id is specified, it returns the last status of that connection; otherwise, it returns the last status of any connection.
This function returns a meaningful value only when the last ODBC query fails (i.e., odbc_exec() returns false).
Number | Parameters and Description |
---|---|
1 | connection_id It contains information about the connection ID |
Try the following example
<?php { $input_ID = odbc_connect("DSN", "user_id", "pass_id"); $sql = "SELECT ProductName, UnitPrice FROM WrongTable"; if (!$result = @odbc_exec($input_ID, $sql)) { echo "Query error! ODBC error: ", odbc_errormsg(); } else { while (odbc_fetch_row($result)) { echo odbc_result($result, "ProductName"), "\n"; } } } ?>