Example krakozybr:
In shape
Connect as follows:
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname); if ($mysqli->connect_errno) { echo "ΠΠ΅ ΡΠ΄Π°Π»ΠΎΡΡ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠΈΡΡΡΡ ΠΊ MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } Below is the code that adds the record to the database. utf8_general_ci encoding utf8_general_ci , utf8 script, run from different servers, one result. The ajax request encoding that writes data to variables is also utf8 , the encoding of variables that php operates on is also utf8 . (checked through the function). I output variables to the browser console via ajax from php and they are not displayed as crackers! I do not know what to do.
$stmt = $mysqli->prepare('INSERT INTO users_1 ( user_id, user_status, user_email, user_pass, user_name, user_surname, user_avatar) VALUES (NULL, "2", ?, ?, ?, ?, "/front/img/users/user.png");'); $stmt->bind_param('ssss', $this->email, $this->pass, $this->name, $this->surname); /* Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄Π³ΠΎΡΠΎΠ²Π»Π΅Π½Π½ΠΎΠ³ΠΎ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ */ if (!$stmt->execute()) echo "ΠΠΎΠ΄ΠΈΡΠΎΠ²ΠΊΠ° ΠΈΠΌΠ΅Π½ΠΈ " . mb_detect_encoding($this->name); /* ΠΠ°ΠΊΡΡΡΠΈΠ΅ ΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΡ ΠΈ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ*/ $stmt->close();