[FX.php List] Snippet: Displaying Error Code Messages
Edward L. Ford
elford at cs.bu.edu
Mon Mar 19 23:41:14 MDT 2007
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20070320/183ca64b/attachment-0001.html
More information about the FX.php_List
mailing list