0

i have some hindi and urdu writing stored in my database xampp there i set utf8_unicode_ci and firstly i wrote this line <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> on my webpage before <title> tag and then i replace uper line with this line <meta charset="utf-8"/>.

When i insert values in 'phpmyadmin' and show those values on webpage it shows ????? question marks on webpage but in 'phpmyadmin' it shows fine uni-code writing.

And then i update those uni-code columns through my webpage after updating those values they they got nice view of writing on webpage but now this time in database column it shows آب Ùˆ Ûوا these type or charters.

now i m not getting what happning i correct one side, other side transformed in to 'unicode-less'.

this is my web page code and i m using php 5.6.11

<!doctype html>
<html>
<head>
<link href="drop_down.css" rel="stylesheet" type="text/css" />
<link href="tooplate_style.css" rel="stylesheet" type="text/css" />

<meta charset="utf-8"/>
<title>Main Page</title>
</head>
<body>
<div>
      <div align="right"> <form action="logout.php" method="post"> <input type="submit" value="Log Out" class="Lbtn" name="L_btn"> </form> </div>
      <header align="center"><a href="index.html"> Talash -e- Haraf </a>      </header>      
          <nav align="center">
            <form action="" method="post">
              <input name="srch" type="text" class="searchbar"  placeholder="Select language and type word here">
              <select name="drp_dwn" class="dropdown dropdown-select" onchange="location = this.options[this.selectedIndex].value;">
                <option>--Please Select--</option>
                <option value="srch_ru.php">Roman</option>
                <option value="srch_e.php">English</option>
              </select>
              <input name="btn" type="submit" class="button" value="Search">
            </form>
          </nav>     
        <div align="right">
                        <table class="responstable">
                                <tr>
                                    <th>Pos</th>
                                    <th>Roman</th>
                                    <th>Urdu</th>
                                    <th>Significance</th>
                                    <th>Hindi</th>
                                    <th>English</th>
                                    <th>Type</th>
                                    <th>Action</th>
                                </tr>
                                <tr>
                                    <?php
                                        $db=mysqli_connect("localhost","root","","app");

                                        foreach($db->query('SELECT * FROM lafaz') as $obj)
                                        {
                                    ?>
                                    <td> <?php  echo $obj["pos"] ?></td>
                                    <td> <?php  echo $obj["roman"] ?></td>
                                    <td> <?php  echo $obj["urdu"] ?></td>
                                    <td> <?php  echo $obj["important"] ?></td>
                                    <td> <?php  echo $obj["hindi"] ?></td>
                                    <td> <?php  echo $obj["english"] ?></td>
                                    <td> <?php  echo $obj["type"] ?></td>
       <td> <a href="detail.php?id=<?php echo $obj['id']; ?>"> <img title="View Detail" src="detail.png" width="40px" height="35px"/> </a>
            <a href="edit.php?id=<?php echo $obj['id']; ?>"> <img title="Edit Item" src="edit.png" width="40px" height="35px"/> </a>
            <a href="delete.php?id=<?php echo $obj['id']; ?>"> <img title="Delete Item" src="delete.png" width="40px" height="35px"/> </a> </td>  
                                </tr>
                                <?php
                                    }
                                ?>
                        </table>
         </div>

</div>
</body>
</html>
Ausaf Sharif
  • 51
  • 2
  • 12
  • 1
    That `` tag is old… try the new ``. – Sebastian Simon Aug 25 '15 at 06:35
  • What does this have to do with any operating system? The answers in the duplicate are OS-agnostic, it's about PHP, MySQL, HTTP and HTML. Did you actually go through the points listed [here](http://stackoverflow.com/a/279279/476)? If so: update your question with details pertaining to each point. – deceze Aug 25 '15 at 12:26
  • So what about **the largest paragraph** in that other answer about **data access**?! Show some code! – deceze Aug 28 '15 at 07:40
  • 1
    So what of the duplicates exactly have you tried? You probably need to add `$db->set_charset('utf8');` after you connect to the database. Have you tried *that*? – deceze Aug 28 '15 at 12:57

1 Answers1

1

You basically need to make sure the whole chain from database to the response of the webserver all are using UTF-8. You don't give enough information to give more concrete advice, but check two things:

A) Are all your files (.php, etc.) UTF-8? Your text editor or IDE should show that information and allow you to convert them if not.

B) Meta tags in the HTML are not the right way to go. They are only a fallback if your web server isn't configured correctly. Use the developer tools built into your browser (usually reachable with F12, use the "network" tab) to check if the server returns a Content-Type header with a charset, e.g.

Content-Type: text/html; charset=utf-8

If not add the line

AddDefaultCharset utf-8

to your Apache web server configuration (http.conf or .htaccess).

You'll need to give much more information, if you need more help.

RoToRa
  • 37,635
  • 12
  • 69
  • 105