php - Incorrect string value for Croatina characters -


i have html form , php script inserting values in mysql table. table fields set utf8_unicode_ci. while inserting croatian letters (žšđčć) error incorrect string value: '\x9a\xf0\xe8... etc column name @ row 1. i've found searching google , 1 of solution change field ut8mb4 still have same problem.

i'm running mysql 5.6.14, php 5.5.11 on xampp 1.8.3

this html file:

<!doctype html> <html> <head> <body> <meta http-equiv="content-type" content="text/html; charset=utf-8" />    <form name="prijava" method="post" action="insert.php"> <fieldset> <legend>personal information:</legend> ime:<br> <input type="text" name="_ime" maxlength="50"> <br> prezime:<br> <input type="text" name="_prezime" maxlength="50"> <br> spol:<br> <input type="radio" name="_spol" value="m" checked>m <br> <input type="radio" name="_spol" value="z">Ž <br> godište:<br> <input type="text" name="_godiste" maxlength="4"<br> <br>e-mail adresa:<br> <input type="text" name="_emailadresa" maxlength="50"> <br> grad/mjesto:<br> <input type="text" name="_gradmjesto" maxlength="50"> <br> tip:<br> <input type="radio" name="_tip" value="klub" checked>klub <br> <input type="radio" name="_tip" value="udruzenje">udruženje <br> <input type="radio" name="_tip" value="solo">solo <br> <br> <p><input onchange="this.setcustomvalidity(validity.valuemissing ? 'molimo vas potvrdite da prihvaćate uvijete!' : '');" id="field_terms" type="checkbox" required name="terms"> prihvaćam <u>uvijete</u></p> <input type="submit" value="submit"> </fieldset>  <a href="select.php">pregled popisa prijavljenih natjecatelja</a> </form>  </body> </head> </html> 

and php:

<?php  include 'config.php';  header("content-type: text/html;charset=utf-8");  if (!isset($_post['_ime']) || !isset($_post['_prezime']) || !isset($_post['_spol']) || !isset($_post['_godiste']) || !isset($_post['_emailadresa']) || !isset($_post['_gradmjesto']) || !isset($_post['_tip'])) {     died ("nisu popunjena svi podaci!"); } else { $ime = $_post['_ime']; $prezime = $_post['_prezime']; $spol = $_post['_spol']; $godiste = $_post['_godiste']; $email = $_post['_emailadresa']; $grad = $_post['_gradmjesto']; $tip = $_post['_tip'];   $sql_insert = "insert prijave (idunos, ime, prezime, spol, godiste, email, grad, tip) values (null, '$ime', '$prezime', '$spol', '$godiste', '$email', '$grad', '$tip');";  mysql_query($sql_insert) or die(mysql_error()); mysql_close($con);  }   // slanje poruke  $to      = $email; $subject = 'prijava na utrku'; $message = 'ovdje ide poruka'; $headers = 'from: webmaster@example.com' . "\r\n" .     'reply-to: webmaster@example.com' . "\r\n" .     'x-mailer: php/' . phpversion();  if (mail($to, $subject, $message, $headers) ) { header('location: finish.html'); }   ?> 

what else solve problem?

when have deal special characters @ couple things:

  1. database, table , field character sets set utf8_unicode_ci.
  2. use header modify http header. header("content-type: text/html;charset=utf-8");
  3. specify default character set used when sending data , database server: mysqli_set_charset($connect, 'utf8'); helpfull link.

so think problem in connection between script , database.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -