1 Reply Latest reply on Mar 12, 2010 3:39 PM by JohanVelthuis

    php dataservice mysql utf8 problem


      I generated a service from flash builder 4 beta2.

      When I use Test Operation some records give this error:

      InvocationTargetException:There was an error while invoking the operation. Check your operation inputs or server code and try invoking the operation again.


      Reason: An error occured while reading response sent by server. Try encoding the response suitably before sending it. e.g. If a database column contains UTF-8 characters then use utf8_encode() to encode its value before returning it from the operation.


      The mysql table is in latin1 character set, but it's possible that there are some utf8 characters in it.

      The strange thing is, that after some tests, the fields giving the problem sometimes just contain ordinary ascii characters


      Anyone has a workaround/solution?

        • 1. Re: php dataservice mysql utf8 problem
          JohanVelthuis Level 1

          I found a solution for the error in the previous example



          I changed the last few lines of the autogenerated get...byItemID to this:


                    if(mysqli_stmt_fetch($stmt)) {
                      $utf8row = new stdClass();
                      foreach($row as $key => $value){
                          if(is_string($value) $value = utf8_encode($value);
                          $utf8row->$key = $value;
                      return $utf8row;
                  } else {
                      return null;


          And the get..All() about the same, except the return $utf8row is there: $rows[] = $utf8row;