0

I have a form that similar to one below.

   <form action="" method="POST">
     <input type="text" name="header" />
     <textarea id="ck_editor" name="content"></textarea>
   </form>

When form sent I replace special characters like Ğ, Ş, Ü with their corresponding html entity. Then insert edited string to database with PHP/MySQLI. content is inserted without any problem. But when it comes to header, it is cutted of after special character's position.

When I want to insert

Türkçe Karakter

It inserted to table like

T

I echo out header, content variables - without any problem - to notify whether inserting proccess is successel or not. MySQL Table

icerik_id INT(11) AUTO_INCREMENT PRIMARY
icerik_baslik VARCHAR(255) 
icerik_icerik TEXT
icerik_durum INT(11) DEFAULT = '1'
collation utf8_unicode_ci

How can I solve this problem?

PHP Code // (icerik = content) (baslik = header)

 if ($_POST) {

    ... 

    if ($ekle == true) {
            // Girdileri Düzenle
            // HTML Entity
            $baslik = htmlentities($baslik, ENT_COMPAT, "UTF-8");
            $icerik= htmlentities($icerik, ENT_COMPAT, "UTF-8");


            $ekle_db = $db->query("INSERT INTO icerikler SET
                icerik_baslik = '$baslik',
                icerik_icerik = '$icerik'
            ");

            if ($ekle_db) {
                $ekle_msg[] = "<span style='color: rgba(140,200,30,1)'>İçerik Başarıyla Eklendi:</span> $baslik";
                $ekle = true;
            } else {
                $ekle_msg[] = "<span style='color: red'>İçerik Eklenenemdi.</span>";
                $ekle = false;
            }
        }

        ...
     }
Zeki
  • 73
  • 7
  • 1
    If the problem occurs when you try to insert the string into your database using PHP, then showing the PHP code that you use to do that might be useful as well – Mark Baker Aug 03 '14 at 11:52
  • Please show your code. If you're not using parametrized queries, you need to escape your input. Also, what is the collation of the table? – Barmar Aug 03 '14 at 12:04
  • @MarkBaker and Barmar I edited the question. – Zeki Aug 03 '14 at 12:58

0 Answers0