dousheyan0375 2014-07-03 02:52
浏览 7

我需要特殊字符的帮助到我的phpmyadmin

Am try to insert strings containing special characters like single quote and double quote (',") but it's refusing to insert or even when it does and I want to display it in HTML it shows codes instead the character I typed.

For instance I have a form when i type things with single quotation mark like this These are an example's of them because of the single quote it does not insert it into myphpadmin and if I display them it shows characters like this 
&#13 please someone should me correct these two mistakes

  • 写回答

1条回答 默认 最新

  • dongzinen1061 2014-07-03 02:59
    关注

    Is this pasted content from MS word? It may be that they are the smart quotes or curly quotes instead of the normal quotes If so I use this function to clean them

    ( normal quotes are ' single " double ).
    
    function convert_smart_quotes($text){
            $search = array(
                "\xe2\x80\x98", // "'"
                "\xe2\x80\x99", // "'"
                "\xe2\x80\x9c", // '"'
                "\xe2\x80\x9d", // '"'
                "\xe2\x80\x93", // '-'
                "\xe2\x80\x94", // '-'
                "\xe2\x80\xa6", // '...'
                chr(145),
                chr(146),
                chr(147),
                chr(148),
                chr(150),
                chr(151),
                chr(133)    
            );
    
            $replace = array(
                "'",
                "'",
                '"',
                '"',
                '-',
                '-',
                '...',
                "'",
                "'",
                '"',
                '"',
                '-',
                '-',
                '...'
            );
    
            $text = str_replace($search, $replace, $text);
    
            return $text;
        }
    

    p.s. the OP would most likely have a syntax error in his query if they where normal quotes and not escaped properly.

    评论

报告相同问题?