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 725649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:21:39+00:00 2026-05-14T06:21:39+00:00

my data includes arabic characters which looks like garbage in mysql but displays correctly

  • 0

my data includes arabic characters which looks like garbage in mysql but displays correctly when run on browser. my questions:

  • how do i html-encode the output?
  • if i add this to all my files: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> i get this error: Error: Incorrect string value: '\xE4\xEE\xC3\xD8\xEF\xE6...' for column 'cQuotes' at row 1

i’m working on php/mysql platform.

insertion form in html:

<!doctype html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Your Favorite Quotes</title>
<link rel="stylesheet" type="text/css" href="style.css" /> 
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" src="scripts/jquery-1.4.2.js"></script>
<script src="scripts/jquery.validationEngine-en.js" type="text/javascript"></script> 
<script src="scripts/jquery.validationEngine.js" type="text/javascript"></script>
<script type="text/javascript">
            $(document).ready(function() { 
                $("#submitForm").validationEngine() 
            })  
</script>
</head>
<body>

<div class="container">
<div class="center_div">
<h2>Submit Your Quote</h2>
<fieldset>
<form id="submitForm" action="qinsert.php" method="post">
<div class="field">
<label>Author: </label>
<input id="author" name="author" type="text" class="validate[required,custom[onlyLetter],length[0,100]]">
</div><br />
<div class="field">
<label>Quote: </label>
<textarea id="quote" name="quote" class="validate[required, length[0,1000]]"></textarea>
<br />
</div>
<input id="button1" type="submit" value="Submit" class="submit" /><br />
<input id="button2" type="reset" value="Reset" /> 
</form>
</fieldset>
</div>
</div>


</body>
</html>

//////////////////////

query in php:

//<?php
//header('Content-Type: text/html; charset=UTF-8');
//?>
<!doctype html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style2.css" /> 
<title>Your Quote Databank</title>
</head>
<body>

<?php
include 'config.php';

echo "Connected <br />";


//check for quotes and apostrophes

$author = '';
$quote = '';

$author = $_POST['author'];
$quote = $_POST['quote'];

$author = mysql_real_escape_string(trim($author)); 
$quote = mysql_real_escape_string(trim($quote)); 


//**************************


//validating data

$query = "SELECT * FROM Quotes where cQuotes = '$quote' limit 1;";

$result = mysql_query($query, $conn);

//now check that the number of rows is 0

if (mysql_num_rows($result) > 0 ) {
header("Location: /error.html");
exit;
}



//inserting data
//mysql_query("SET NAMES 'utf8'");
//mysql_query("SET CHARACTER SET utf8");
$sql="INSERT INTO Quotes (vauthor, cquotes)
VALUES ('$author', '$quote')";

if (!mysql_query($sql,$conn))
  {
  die('Error: ' . mysql_error());
  }
echo "<div class='container'><p><label class='lbl_record'> Record Added Successfully!</label>";
echo "<a href='qform.html'> Submit a New Quote!</a></p>";

//**************************


//selecting data
$result = mysql_query("SELECT * FROM Quotes ORDER BY idQuotes DESC");

echo "<div class='center_div'>";
echo "<table>
<thead>
<tr>
<th>Author</th>
<th>Quotes</th>
</tr>
</thead>";

while($row = mysql_fetch_array($result))
  {
  echo "<tbody><tr>";
  echo "<td width='150px'>" . $row['vAuthor'] . "</td>";
  echo "<td>" . $row['cQuotes'] . "</td>";
  echo "</tr>";
  }
echo "</tbody></table>";
echo "</div></div>";
//**************************

include 'close_config.php';

?>

</body>
</html>
  • 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-14T06:21:39+00:00Added an answer on May 14, 2026 at 6:21 am
    Incorrect string value: '\xE4\xEE\xC3\xD8\xEF\xE6...'
    

    That looks like an Arabic string encoded in ISO-8859-6. You will get this error if you have received an ISO-8859-6 byte string and are attempting to insert it into a UTF-8 database table.

    Your script should not have received ISO-8859-6 from the browser, if your form page is correctly marked up as UTF-8 as the meta would imply. Check in the browser that when the form is displayed, the View->Encoding menu has ‘UTF-8’ ticked. The <meta> might be overridden by the web server passing back a real Content-Type: text/html;charset=... header.

    This could also possibly happen if your PHP is trying to use the wrong charset to talk to the server. I see you’ve commented out a SET NAMES… I’d use mysql_set_charset('utf8'); in preference.

    echo "<td>" . $row['cQuotes'] . "</td>";
    

    You need to HTML-encode the output here but not because of charset issues. Any < and & characters need encoding in the text otherwise they can inject unwanted HTML markup, including JavaScript, in which case you have cross-site-scripting problems.

    echo '<td>'.htmlspecialchars($row['cQuotes']).'</td>';
    

    Aside: …however, PHP is a templating language. Use it, don’t fight it by trying to do string templating yourself.

    <table>
        <?php while ($row= mysql_fetch_array($result)) { ?>
            <tr>
                <td width="150"><?php h($row['vAuthor']) ?></td>
                <td><?php h($row['cQuotes']) ?></td>
            </tr>
        <?php } ?>
    </table>
    

    (width="150px" doesn’t work, px is for CSS only.) The above assumes a helper function like this to stop you having to type htmlspecialchars so much:

    function h($s) {
        echo htmlspecialchars($s, ENT_QUOTES);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I inserted data in a MySQL database which includes Arabic script. While the output
Thanks for reading this. I am dynamically generating some data which includes a select
I have a data model that includes common columns like addedBy, editedby (user), addedDate,
I have a .rc file which is used to include some text data in
I need to replicate data from Microsoft SQL Server to MySQL or PostgreSQL. The
We want to include data visualization in our desktop GUI (mostly timelines and graphs;
What is the best way to include data in an HTML page? The data
When data binding two elements together, how can I include the binding information AND
Data: a dependency list, already verified to be acyclic. So here, 'a' depends on
Data table structure is: id1,id2,id3,id4,... (some other fields). I want to create summary query

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.