[FX.php List] Snippet: Displaying Error Code Messages
Gjermund Gusland Thorsen
ggt667 at gmail.com
Tue Mar 20 03:06:17 MDT 2007
ALWAYS write those errorcodes with datetime, browser and remote IP to
a FileMaker log-table, there is no need to inform web users on why
this happened.
ggt667
On 3/20/07, Edward L. Ford <elford at cs.bu.edu> wrote:
> Actually, to expand on this a little more, when I do use this in
> applications, I define a constant at the top of a file that lets me quickly
> go into the file and turn these error code messages on and off. Example:
>
>
> define('ERROR_MSGS_ON', false); // Turns on error code reports in this file
> include_once('FX.php');
> include_once('connection_data.php');
> include_once('FMErrors.php');
>
> Later on, when the code is doing database work where an error can occur, I
> might do something like:
>
> if(ERROR_MSGS_ON) {
> echo("FileMaker Insertion Error Code: " . $ErrorCode . ", " .
> $errorsList[$ErrorCode] . "\n");
> }
>
> where $ErrorCode is the error code given when the code logic to the database
> fails, and the $errorsList variable is the array in the FMErrors file.
>
> I hope this helps some of the less experienced FX folks.
>
> --Ed
> -----------------------------------
> http://www.edwardford.net
>
>
> On Mar 20, 2007, at 1:41 AM, Edward L. Ford wrote:
> I once used a similar technique below in my solutions, but have since
> discarded it. It's great for debugging problems and you don't know what the
> error code means, but if you use this in a production solution, you open
> yourself up to a security hole if the error is made through a coding error
> or a query error that isn't caught before it's sent to FileMaker, and
> essentially provide an attacker with a starting point to try and see where
> any weaknesses like in the code. Thus, I occasionally use this when I get a
> lot of errors and want a quick way to figure out the problem, but for
> production solutions, I only display a generic error message.
>
>
> Just my two cents,
> --Ed
> -----------------------------------
> http://www.edwardford.net
>
>
>
> On Mar 19, 2007, at 10:36 AM, Jonathan Schwartz wrote:
>
> Hi Folks,
>
> Wanted to offer up a simple little snippet that I created today to help with
> error reporting. Experienced fx.php users may already be using this
> technique....so this is for the beginners/intermediate fx.php users.
>
> Up to this time, I have been using the FMErrors.php file as a simple
> reference tool to look up the meaning of error codes thrown by FMP/fx.php.
> The file is buried deep in the FX folder. That gets tired after the 1,000th
> time. On my last iteration, I realized that the file is actually an array:
> the error number is the key and the error phrase is the value. Now that I
> am past my array-phobia, the answer seems clear. By simply requesting the
> value associated with the current error number (key), the error phrase can
> easily be displayed, like this:
>
> include(FMErrors.php);
> <snip>
> if($searchResult['errorCode'] != '0' && $searchResult['errorCode'] != '401')
> {
> $msg = 'Oops! Your search didn\'t return any results due to a problem:
> Error#'.$searchResult['errorCode']. '
> '.$errorsList[$searchResult['errorCode']];
> }
> ...and then display the $msg where appropriate.
>
>
> In this case, I have assumed that all errors other than "0" (No error) and
> "401" (No records found) are problems, and that the message should be
> displayed. Your mileage may vary.
>
> HTH,
>
> Jonathan
> --
> Jonathan Schwartz
> Exit 445 Group
> jonathan at exit445.com
> http://www.exit445.com
> 415-381-1852
> FileMaker 8 Certified Developer
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
More information about the FX.php_List
mailing list