zoukankan      html  css  js  c++  java
  • Debugging Tip: “Disallowed Key Character” Error In CodeIgniter

    关于这个错误。看到有人直接修改了 Input.php 。觉得不妥,查阅了一下,一个令我满意的答案是

    After 6 hours of massive anxiety, stress, near tears, one pound on my desk, and some hair pulling, I tracked down the source of a nagging Disallowed Key Character error that I received while using CodeIgniter: an extra line break.

    The line feed (LF) and carriage return (CR) characters (and their hex code equivalents (%0D and %0A) are forbidden in CodeIgniter’s framework. The hard part is tracking down exactly where that extra line break character lives.

    In my case, there was an extra line of blank, barren, not-all-that-obvious white space at the very, very end of one of my controller files, just after the closing ?>.

     

    所以这是一个编程习惯的问题,so,

    delete *anything* after the closing ?> -- including white space and line breaks -- or remove the ?>.

    如果你想搞清楚哪个字符的问题,可以尝试这样

    In the core CI code in system/libraries is a file called input.php I made a small modification to that file so that it would show the actual data in question.

    Around line number 199

    function _clean_input_keys($str)
    {
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
    exit('Disallowed Key Characters: '.$str); // Added the variable to display.
    }

    return $str;
    }

    另外一种情况,disallowed characters in a POST array

    In my case, I had single-quotes as part of the variable name. My fingers mixed up PHP array syntax and HTML form syntax.

    <!-- will cause the error -->
    <input type="text" name="fieldname['foo']" value=""> 
    
    <!-- won't cause the error. besides, this is the proper syntax. -->
    <input type="text" name="fieldname[foo]" value="">
    

    kalodont points out this can also happen when using accented characters, such as ó or ñ as keys in your array.

  • 相关阅读:
    Error (0xc0000225) installing Windows 8 R2 on VirtualBox
    网页宽高自适应大小
    C# Java DES加密解密
    JS获取DropDownList的value值与text值
    用Aspose.Cells控件读取Excel
    Extending your SharePoint 2007 site with Microsoft ASP.NET AJAX 3.5
    页面自定义拖拽布局
    OutLook 2010 收件箱子文件夹收到新邮件时没有桌面通知
    PeopleEditor的取值及赋值
    deprecate (声明不赞成)
  • 原文地址:https://www.cnblogs.com/leonbond/p/2550919.html
Copyright © 2011-2022 走看看