www.webdeveloper.com
Results 1 to 6 of 6

Thread: How to disable Warnings

  1. #1
    Join Date
    Sep 2004
    Location
    Sri Lanka
    Posts
    471

    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

    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:\wamp\test\index.php on line 7
    Could not connect to the Database.

    Text in Red generated by PHP & ODBC.
    Text in Blue generated by the die() statement.

    The following is the code used.

    PHP Code:
            $odbc odbc_connect($dsn,$user,$pass) or die('Could not connect to the Database.'); 
    It will be a great help if someone let me know how to limit the error message to die().

    Best Regards
    Last edited by GUIR; 06-03-2007 at 10:14 AM.

  2. #2
    Join Date
    May 2007
    Posts
    93
    Use the error_reporting() function

    error_reporting(E_ERROR | E_PARSE);
    http://www.php.net/error_reporting

  3. #3
    Join Date
    Sep 2004
    Location
    Sri Lanka
    Posts
    471

    Smile Thanks

    Hi!

    Thank you very much for your support.

    It works great.

    Best Regards

  4. #4
    Join Date
    Dec 2012
    Posts
    1

    Disabling warnings in PHP

    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

  5. #5
    Join Date
    Oct 2011
    Posts
    123
    use simplified coding

  6. #6
    Join Date
    Dec 2012
    Location
    Lahore, Pakistan
    Posts
    10

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles