0

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

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
rapulu
  • 160
  • 1
  • 10
  • You should try and escape your characters! http://stackoverflow.com/questions/881194/how-to-escape-special-character-in-mysql – J A Jul 03 '14 at 02:57

1 Answers1

0

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.

ArtisticPhoenix
  • 21,464
  • 2
  • 24
  • 38