Try using set names
public function insert($sql) {
$conn = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// $conn->set_charset("utf8");
$conn->query("SET NAMES 'utf8'");
if ($conn->query($sql) === TRUE) {
return 1;
} else {
return 0;
}
$conn->close();
}
From MySQL (http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html):
- SET NAMES 'charset_name' [COLLATE 'collation_name']
SET NAMES
indicates what character set the client will use to send SQL statements to the server. Thus, SET NAMES 'cp1251'
tells the server, “future incoming messages from this client are in character set cp1251.” It also specifies the character set that the server should use for sending results back to the client. (For example, it indicates what character set to use for column values if you use a SELECT statement.)
A SET NAMES 'charset_name'
statement is equivalent to these three statements:
SET character_set_client = charset_name;
SET character_set_results = charset_name;
SET character_set_connection = charset_name;
Setting character_set_connection to charset_name also implicitly sets collation_connection to the default collation for charset_name. It is unnecessary to set that collation explicitly. To specify a particular collation, use the optional COLLATE
clause:
- SET CHARACTER SET charset_name
SET CHARACTER SET
is similar to SET NAMES
but sets character_set_connection and collation_connection to character_set_database and collation_database. A SET CHARACTER SET charset_name
statement is equivalent to these three statements:
SET character_set_client = charset_name;
SET character_set_results = charset_name;
SET collation_connection = @@collation_database;
Setting collation_connection also implicitly sets character_set_connection to the character set associated with the collation (equivalent to executing SET character_set_connection = @@character_set_database). It is unnecessary to set character_set_connection explicitly.
My opinion is that in some point the proper character set for the field description is not specified when using stored procedure. Do check again that your database/table/field have as character set utf8_general_ci
From MySQL (http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html):
Example: Suppose that column1
is defined as CHAR(5) CHARACTER SET latin2
. If you do not say SET NAMES
or SET CHARACTER SET
, then for SELECT column1 FROM t
, the server sends back all the values for column1
using the character set that the client specified when it connected. On the other hand, if you say SET NAMES 'latin1'
or SET CHARACTER SET latin1
before issuing the SELECT statement, the server converts the latin2 values to latin1 just before sending results back. Conversion may be lossy if there are characters that are not in both character sets.