S
S
sergealmazov2016-02-09 16:42:14
MySQL
sergealmazov, 2016-02-09 16:42:14

How to write data to MySQL through mysqli in Russian?

I'm trying to write data using

$conn = new mysqli($servername, $username, $password, $database);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 

    $sql = "INSERT INTO orders (name) VALUES ('Кеша');";

    if ($conn->query($sql) === TRUE) {
        echo "New record created successfully";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }

But instead of Kesha, you get krakozyabry.
What to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Edheldor, 2016-02-09
@Edheldor

Set encoding. http://php.net/manual/ru/mysqli.set-charset.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question