0

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

JPMD
  • 644
  • 1
  • 7
  • 19
  • Contact the administrators for your server. – frosty Mar 22 '16 at 13:22
  • Resin uses `Quercus` which from what I can gather is a JAVA implementation of PHP i.e. I think that means PHP converted to JAVA code. I am guessing they did not implement `MYSQLI` completely or very well, or there is a subtile difference in this area. Just goes to show you should develop on a matching environmant to that which you want to deploy on. – RiggsFolly Mar 22 '16 at 13:30
  • Thanks @frosty.The administrators of the server are clueless (this is a very old deployment...)... – JPMD Mar 23 '16 at 13:09
  • Thanks @RiggsFolly. There's no portable Resin server I believe, So I can not develop in it.... Yes, Resin uses a java implementation of Php, so there must be a difference in the code or not even that function implemented...Thanks for your comments – JPMD Mar 23 '16 at 13:10

0 Answers0