I read on <a href="http://www.php.net/manual/en/language.operators.errorcontrol.php">php.net</a> that setting track_errors to true in php.ini and using the @ in front of my OCILogon would set the error in a variable called $php_errormsg.

I manually set error_reporting (E_ALL);

and this code:

$conn = @OCILogon("v","v",$db)
  or die("Query failed: error was '$php_errormsg'");

gives me this warning on the page:

Warning: Undefined variable: php_errormsg in /www/html/dot.com/all.php on line 18
Query failed: error was ''

Why isn't $php_errormsg being given a value when the OCILogon is obviously dying?

    6 months later

    did you use it in a function and forgot to make it golbal?

      No, and I never got that to work. Instead, I've been using OCIError to retrieve the error message.

        6 months later

        Hello,
        I had the same problem and have been looking all over the web trying to resolve the issue. After an hour of looking, I FINALLY (in three unrelated places) found different bits of information that made this work.

        First is - need to have track_errors enabled. This is normally done in php.ini and is OFF by default. To turn it on, somewhere at the top of your code type:
        ini_set("track_errors", "1");

        Second, as you know, declare $php_errormsg as global (I did it in same routine as where I used it)

        The third source of info was how to turn on track_errors on a script-only basis.

        This has worked for me, hope it helps you as well and anyone else that's had trouble with it, because I've seen quite a few people that have the same problem and have not been able to resolve it. Going to do posts on all those sites now...

        Frog wrote:

        I read on <a href="http://www.php.net/manual/en/language.operators.errorcontrol.php">php.net</a> that setting track_errors to true in php.ini and using the @ in front of my OCILogon would set the error in a variable called $php_errormsg.

        I manually set error_reporting (E_ALL);

        and this code:

        $conn = @OCILogon("v","v",$db)
          or die("Query failed: error was '$php_errormsg'");

        gives me this warning on the page:

        Warning: Undefined variable: php_errormsg in /www/html/dot.com/all.php on line 18
        Query failed: error was ''

        Why isn't $php_errormsg being given a value when the OCILogon is obviously dying?

          Write a Reply...