I have a problem with MySqli for which I would appreciate your help or comments. I am trying to use Set_charset("utf8") in a MySQL database running in a Resin webserver. I have looked and tried several options found here in other posts, like:
$conn = new mysqli($servername, $user, $password, $dbname);
$conn->query('SET NAMES utf8');
or
$conn->set_charset("utf8");
These commands do work on a local Apache server running mysql-5.6.20 and php 5.4.31.
But they do not work on a Resin webserver running MySQl 5.6 and Php 5.5. I did the development in a local Apache server (uAMP) and then copied the php file to the Resin webserver...
I found this code in WWW3S to set and verify the charset:
<?php
$mysqli = new mysqli("localhost", "root", "root", "bdtest");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Initial character set: %s\n", $mysqli->character_set_name());
/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $mysqli->error);
exit();
} else {
printf("Current character set: %s\n", $mysqli->character_set_name());
}
$mysqli->close();
?>
I get the correct result when I run it in the Apache local server:
Initial character set: latin1 Current character set: utf8
But in the Resin server I get this:
Initial character set: latin1 Error loading character set utf8:
So I guess, it must be something with the set_charset not being properly interpret in Resin. But I have no clues why (If I could, I just would trash the Resin and change to Apache... but I cannot).
Any help, ideas, comments will be greatly appreciated. Thanks!
João