Let's say I do a odbc_connect call, deliberately using erroneous information, as follows:
<?PHP odbc_connect('bogus','bogus','bogus'); ?>
Now, the manual states that odbc_connect "[r]eturns an ODBC connection id or 0 (FALSE) on error". I'm okay with the 0 being returned, but when I'm running the file (using Wampserver), I also receive error messages telling me that something went wrong.
I would like to suppress this error message, since I'm trying to build a PHP file that only echoes a certain piece of text, like "unsuccessful", when the information for the database call was wrong.
Use a
try-catch
:You can also use
@
to suppress error messages on a single line - but it isn't good practice.Error messages are there for a reason, don't ignore them. Use something like @Matt suggests and trap them as needed - not just hush them up.
You can use the error-suppression operator
@
.