• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
An error occurred translating the query string to UTF-16: No mapping for the Unicode

#1
Hi All,
I have a problem when using CI 2.14 or 2.1.0 with SQL Server 2012. I use sqlsrv for dbdriver. I got error massage like this when try to Login in my application. This error was happened when i was tried to input my password form with number, symbols and another else except character.If I only input password form with character everthing still working good. I have used google for solved my problem and only got this tutorial but I still got error when I tried 

http://stackoverflow.com/questions/91787...odeigniter

Code:
A Database Error Occurred
Error Number: IMSSP
An error occurred translating the query string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page. .
SELECT * FROM tbl_mst_user WHERE USER_ID = 'opsup4' AND USER_PASSWORD = '���hbhb'
Filename: C:\xampp\htdocs\kerjaan\TreasuryOperation\system\database\DB_driver.php
Line Number: 330


This is my Model when insert to database

PHP Code:
public function validate(){
        
$USER_ID $this->security->xss_clean($this->input->post('USER_ID'));
 
       $USER_PASSWORD $this->security->xss_clean($this->input->post('USER_PASSWORD'));
 
       $EnkripsiUserPassword=Enkripsi($USER_PASSWORD);
        
$this->dbuser->where('USER_ID'$USER_ID);
 
       $this->dbuser->where('USER_PASSWORD'$EnkripsiUserPassword);
 
       // Run the query
 
       $query $this->dbuser->get('tbl_mst_user');
 
       if($query->num_rows == 1)
 
       {
 
           // If there is a user, then create session data
 
           $row $query->row();
 
           $data = array(
 
                   'USER_IDX' => $row->USER_IDX,
 
                   'USER_ID' => $row->USER_ID,
 
                   'USER_NAME' => $row->USER_NAME,
 
                   'UNIT_ID' => $row->UNIT_ID,
 
                   'DEPARTMENT_ID' => $row->DEPARTMENT_ID,
 
                   'DIVISION_ID' => $row->DIVISION_ID,
 
                   'BRANCHBSMI_ID' => $row->BRANCHBSMI_ID,
 
                   'GROUP_NAME' => $row->GROUP_NAME,
 
                   'GROUP_DESCRIPTION' => $row->GROUP_DESCRIPTION,
 
                   'validated' => true
                    
);
 
           $this->session->set_userdata($data);
 
           return true;
 
       }
 
       // If the previous process did not validate
 
       // then return false.
 
       return false;
 
   

And this my file in Third Party folder for Encrypt and Decrpty User input password

PHP Code:
sory edited for any reason :


My question, is this a bug from CI driver for SQL Server ? And how to solved this problem, any advice to me ? This is make me painful

Thank you
Reply

#2
The whole code has more problems except the encoding.

1. You use encryption for passwords. Use hashing.
2. Your encryption algorithm is non-standard, super-weak, and it does not have separate secret data (a key) to be applied. By publishing its code here the encryption is already compromised.

3. To the concrete problem: You may encode the problematic strings using base64 before storing within the password field, on reading apply base64 decoding. This is not a solution, better try to refactor the whole password related code.
Reply

#3
(02-08-2015, 08:03 AM)ivantcholakov Wrote: The whole code has more problems except the encoding.

3. To the concrete problem: You may encode the problematic strings using base64 before storing within the password field, on reading apply base64 decoding. This is not a solution, better try to refactor the whole password related code.

Thank's for your reply, I have another problems, I can't change all value in the password field with base64 because the field passowrd has using by another application. If i change the password it will make big effect to anoher application

Do you have any better idea ? What part of my code have to change to solved my problems ?
Reply

#4
I am out of ideas, this looks tricky to be solved from distance.
Reply

#5
I think you have to convert the string into utf8 like this

PHP Code:
iconv('','UTF-8',$EnkripsiUserPassword); 

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.