Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8057879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:10:34+00:00 2026-06-05T09:10:34+00:00

I want to encode Danish characters before sending them to database. I try to

  • 0

I want to encode Danish characters before sending them to database.

I try to apply this function to them:

private function process_array_elements(&$element){
   $element = utf8_encode($element);
   $element = strip_tags(  $element );
   $element = strtolower ( trim ( $element )  );
   $element = mysql_real_escape_string($element);
   return $element;
}

Like this:

$this->check_line_two = $this->process_array_elements($e);

Now, whenever I try to send the string to the database:

mysql_query("SET NAMES 'utf8'");
$query="INSERT INTO  result_scanned
          SET line_one= '$this->check_line_one',
              line_two='$this->check_line_two',
              line_three='$this->check_line_three',
              advert_id='$this->advert_id',
              scanned='$this->scan_result'";

I get this:

 Incorrect string value: '\xE3\x83\xE2\xB8r ...' for column 'line_three' at row 1

The datatype of the fields in the table are UTF-8 (utf8_unicode_ci), so I must encode my string using the same

This thread is related to my question: Detect encoding and make everything UTF-8.

However, I need to know how to encode any character to UTF-8, before inserting it to the database, otherwise, I get an error as the one aforementioned. I think I need to identify first what kind of characters I am receiving before putting them into database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:10:35+00:00Added an answer on June 5, 2026 at 9:10 am

    utf8_unicode_ci is the collation, you need the character set as utf8 as well:

    CREATE TABLE someTable DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci;
    

    For good measure, make sure that everything is UTF-8 when connecting to MySQL with PHP:

    mysql_connect ("localhost", "DB_USER", "DB_PASSWORD") or die (mysql_error());
    mysql_select_db ("DATABASE_NAME") or die (mysql_error());
    
    mysql_query("SET character_set_client=utf8"); 
    mysql_query("SET character_set_connection=utf8"); 
    mysql_query("SET character_set_database=utf8"); 
    mysql_query("SET character_set_results=utf8"); 
    mysql_query("SET character_set_server=utf8"); 
    mysql_query("SET NAMES 'utf8'");
    

    This is how I connect on the Hebrew gibberish translation website I run, and it handles everything that myself or that users throw at it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do encode the data before saving it to a database table
I want to encode my php sending form in my language. What is wrong
I want to encode passwords for UNIX accounts using the crypt function. I'm using
I have an array of bytes (any length), and I want to encode this
I want to encode this 广东路20号外滩5号7楼,近中山东一路 into this: %e5%b9%bf%e4%b8%9c%e8%b7%af%32%30%e5%8f%b7%e5%a4%96%e6%bb%a9%35%e5%8f%b7%37%e6%a5%bc%ef%bc%8c%e8%bf%91%e4%b8%ad%e5%b1%b1%e4%b8%9c%e4%b8%80%e8%b7%af however urlencode() doesn't seem to
$str = preg_replace('\(look: (.{1,80})\)'Ui, (look: <a href=\dict.php?process=word&q=\\1\>\\1</a>),$str); i want to encode url, but how
I want to encode/compress some binary image data as a sequence if bits. (This
I have a list of unicode objects and want to encode them to utf-8,
I want to encode to ISO-8859-1 a url that contains latin characters like à
I want to encode a message...This is the message that i have generated from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.