/    Sign up×
Community /Pin to ProfileBookmark

How to disable Warnings

Hi!

I’m using PHP to connect to an Access database via ODBC connection.

It is successful, however when there is an error, warning from PHP overrides die() statements given by me. It first shows its’ warning, and then the error message within the die().

But I just want to show the message in die() statement, not the one generated by PHP or ODBC.

The following is an example

[COLOR=”Red”]Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in H:wamptestindex.php on line 7[/COLOR]
[COLOR=”Blue”]Could not connect to the Database.[/COLOR]

Text in [COLOR=”Red”]Red[/COLOR] generated by PHP & ODBC.
Text in [COLOR=”Blue”]Blue[/COLOR] generated by the die() statement.

The following is the code used.

[code=php] $odbc = odbc_connect($dsn,$user,$pass) or die(‘Could not connect to the Database.’); [/code]

It will be a great help if someone let me know how to limit the error message to die().

Best Regards

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@redhatlookJun 03.2007 — Use the error_reporting() function


error_reporting(E_ERROR | E_PARSE);
[/QUOTE]


http://www.php.net/error_reporting
Copy linkTweet thisAlerts:
@GUIRauthorJun 03.2007 — Hi!

Thank you very much for your support.?

It works great.

Best Regards
Copy linkTweet thisAlerts:
@jporter892Dec 08.2012 — There are also other options that you can pass into the error_reporting function, and you can even use the "@" operator to suppress errors... more information described here:

Remove warnings in PHP
Copy linkTweet thisAlerts:
@adumpaulDec 08.2012 — use simplified coding
×

Success!

Help @GUIR spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...