3 Replies Latest reply on Jan 11, 2012 5:53 PM by cj

    Problem with trigger_error

      Hi to All

      I have create this test file:
          $dbHost = "sles11sp1.lan";
          $dbServiceName = "sles11";
          $usr = "test";
          $pswd = "mypwd";
          $dbConnStr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$dbHost.")(PORT=".$dbHostPort."))
          if(!$dbConn = oci_connect($usr,$pswd,$dbConnStr)) {
             $err = oci_error();
             trigger_error('Could not establish a connection: ' . $err['message'], E_USER_ERROR);
          $strSQL = "SELECT TO_CHAR(SYSDATE, 'HH:MI:SS') ctime FROM DUAL";
          $stmt = oci_parse($dbConn,$strSQL);
          if (!oci_execute($stmt)) {
             $err = oci_error($stmt);
             trigger_error('Failed to execute the query: ' . $err['message'], E_USER_ERROR);
          $rslt = oci_result($stmt, 'CTIME');
          print "<h3>The current time is ".$rslt."<h3>";
      When I run the file in the Browser all work fine. But if i modify for example the password in order to verify the connection error, the error is not displayed and the page is empty.

      Can You help me to find wich error is in my php file ?

      Kind Greetings
        • 1. Re: Problem with trigger_error
          Do you need to add "| E_USER_ERROR" to the php.ini setting of error_reporting?
          • 2. Re: Problem with trigger_error
            I want display in the browser a message with error verified during the execution.

            • 3. Re: Problem with trigger_error
              Check your php.ini settings for display_errors and error_reporting. See http://us.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting
              You can find your php.ini location and settings with the phpinfo() function.

              Almost all production PHP applications shouldn't expose internal errors to end users because this is a security leak. Instead, scripts should "catch" errors, log them to a web server-side file, and generate a pretty error page to show the user. See the Error Handling chapter of the updated PHP & XE guide: http://docs.oracle.com/cd/E17781_01/appdev.112/e18555/ch_seven_error.htm#sthref243