Cannot supress display of ODBC warning with PHP function error_reporting()

I am using a blank application to read from an ODBC data source. PHP reports a warning when running a query using sc_select or sc_lookup even when using the plain PHP odbc_exec(). Have tried using the PHP function error_reporting() to suppress the display of the warning, but it has no effect. To test further, I created a basic PHP file outside of Scriptcase. Without error_reporting() the warning is displayed, but when I do use error_reporting() it works to suppress the warning. I can only guess that Scriptcase is turning some of the error reporting back on for at least part of the query process.

Edit: I should note that I am using Scriptcase 9.6.016

If this is in your events then use a @ in front of your call. It will suppress the warning. As a work-around.

Thank you for the suggestion. It didn’t seem to work, but being new to Scriptcase I will show you what I have to make sure I am doing what you suggested properly:

error_reporting( 0 );
$conn = odbc_connect("MyOdbcDsn","","","");
$sql = "SELECT Field1, Field2, Field3 FROM MyTable WHERE Field1 = 12345";
$rs = @odbc_exec($conn,$sql);

From my 2 minute glance online, the warning seems to be an issue with PHP asking for something that the ODBC driver does not support. I don’t like it, but I can live with that as long as I can get Scriptcase in this instance to not show the error in the browser window when the page is requested.

It depends on when the error message is produced. You could use @odbc_connect as well.

It is coming from the call to odbc_exec(). The warning message is specifies that.
Error odbc_exec(): SQLColAttribute can’t handle SQL_DESC_OCTET_LENGTH…

I put the @ in front of odbc_connect as well just to be sure, but it didn’t change the behaviour.

Although, I did notice something else. The message in the plain PHP file says “Warning…” but the message from Scriptcase says “Error…” At the least, it shows that Scriptcase is noticing the error specifically. Another thing that should have clued me in to that is that Scriptcase is also formatting it, i.e. using class=scErrorTable etc.

SC uses its own error_handler to show error messages.
Prepending @ in front of a function call does NOT avoid the error handler to be called.
Before calling odbc_exec you can add this statement:
restore_error_handler ();
to disable SC error handling and it should work.

The problem is that I am not sure how to enable it back afterward.

Just to follow up for any others who are interested, I was eventually informed that you can use sc_warning to turn the warnings off and back on again when needed. It works with the Scriptcase macros as well as other functions such as odbc_exec()

sc_warning = 'off';
sc_select(myDataset, $sql_query, "odbc_connection");
sc_warning = 'on';