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

  • Home
  • SEARCH
  • 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 6653607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:17:27+00:00 2026-05-26T01:17:27+00:00

I have a database defined with charset utf8_general_ci and a table that should store

  • 0

I have a database defined with charset utf8_general_ci and a table that should store some text inserted from a text area form with the same charset.

The form I use to get the text is this:

<form action="submit_text.php" method="post">

    Text:</br>
    <textarea name="text" cols="109" rows="20">
        <?php echohtmlspecialchars($_POST['text']);?>
    </textarea>

    <input name="submit" type="submit" value="save text">

</form>

The php instructions I use to save this text in my database are the following:

$text = $_POST['text'];
$query = "INSERT INTO table_name VALUES (..., '$text', ...)";
$query_result = mysql_query($query) or die (mysql_error());
return $query_result;

I then have a page where I print the text saved in the database table by selecting one element of the table and then echoing the text field of the query result (not showing the query part):

<div class="entry">
    <?php echo $selected_element_of_table['text'];?>
</div>

However, all special characters in the text are screwed up, and neither newlines or tabs are printed correctly.

Does anybody have an idea of what my problem is?
Should I change charset encoding?

Thanks in advance!

  • 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-05-26T01:17:27+00:00Added an answer on May 26, 2026 at 1:17 am

    A few things to try:

    In pages that will display UTF-8 content, in your header include:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    

    In your PHP, before any output to the browser, include the content type PHP header:

    header ('Content-type: text/html; charset=utf-8');
    

    Before you run your SQL to fetch content, use mysql_set_charset:

    mysql_set_charset('utf8',$link); 
    // $link is optional, refers to your DB connection
    

    If you wish breaks/carriage returns to be output, wrap your output text in nl2br($output)

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

Sidebar

Related Questions

I have a database table that has a Unique Key constraint defined to avoid
I have a database table that is a dictionary of defined terms -- key,
In my database I have tables that define types for example Table: Publication Types
I have a database that has two tables. These two tables are defined as:
I have a database that was restored from a SQL 2000 instance to a
I have a pre-defined database that I want to map using Entity Framework 4
Supose that I already have defined my database with a lot of tables (around
I want store some article into database. I use php and mysql. Whether have
I have a database table with the primary column defined as: ID bigint identity
I have Informix database with timestamp field defined as YEAR TO SECOND. When I

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.