PHP load excel spreadsheet - invalid character ??

I am using reader.php to upload a spreadsheet that is then loaded in  to MySQL.

I am getting the following error regarding invalid characters.

Notice: iconv(): Detected illegal character in input string in /var/www/html/admin/readers/Excel/reader.php on line 797

This seems to be the offending function:

    function _encodeUTF16($string){
          $result = $string;
        if ($this->_defaultEncoding){
              switch ($this->_encoderFunction){
                    case 'iconv' :       $result = iconv('UTF-16LE', $this->_defaultEncoding, $string);
                                            break;
                    case 'mb_convert_encoding' :       $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE' );
                                            break;
              }
        }
        return $result;
    }

Any ideas?

Thanks.
Luv2MuffAsked:
Who is Participating?
 
blue_hunterTechnical ConsultantCommented:
   function _encodeUTF16($string){
          $result = str_replace(array("\r","\n"), array("",""), $string);   // try modify this line
        if ($this->_defaultEncoding){
              switch ($this->_encoderFunction){
                    case 'iconv' :       $result = iconv('UTF-16LE', $this->_defaultEncoding, $string);
                                            break;
                    case 'mb_convert_encoding' :       $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE' );
                                            break;
              }
        }
        return $result;
    }
0
 
Luv2MuffAuthor Commented:
Hi blue_hunter,

Thanks for you suggestion. I am just waiting for a quite time on the server to try this out, before getting back to you. Apologies for the delay.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.