1

I want to insert data into MySQL table which is in Hindi. My data is in excel which has font devlys 10.of I copy and paste it in query it does not show up. But if I copy some hindi text from Google translator it takes. I Have tried to use CSV for that particular font but after import it doesn't show Hindi rather shows special characters.

For database ,table and other thing I have checked the things are set properly for utf 8 collation which works well.

If I insert data from translator it shows in Hindi . So question is how to show devlys 10 Hindi font data.?

here is my code...

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo - Import Excel file data in mysql database using PHP, Upload Excel file data in database</title>
<meta name="description" content="This tutorial will learn how to import excel sheet data in mysql database using php. Here, first upload an excel sheet into your server and then click to import it into database. All column of excel sheet will store into your corrosponding database table."/>
<meta name="keywords" content="import excel file data in mysql, upload ecxel file in mysql, upload data, code to import excel data in mysql database, php, Mysql, Ajax, Jquery, Javascript, download, upload, upload excel file,mysql"/>
</head>
<body>

     <?php

      define ("DB_HOST", "localhost"); // set database host
     define ("DB_USER", "root"); // set database user
     define ("DB_PASS",""); // set database password
     define ("DB_NAME","uor"); // set database name

     $link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make b 
     connection.");
     $db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");

     $databasetable = "data";




     set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
     include 'PHPExcel/IOFactory.php';

     // This is the file path to be uploaded.
      $inputFileName = 'discussdesk.xlsx'; 

       try {
       $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
      } catch(Exception $e) {
        die('Error loading file 
       "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": 
      '.$e->getMessage());
      }


     $allDataInSheet = $objPHPExcel->getActiveSheet()-
    >toArray(null,true,true,true);
     $arrayCount = count($allDataInSheet);  // Here get total count of row in 
      that 
      Excel sheet


     for($i=1;$i<=$arrayCount;$i++){
     $name = trim($allDataInSheet[$i]["A"]);
     $email = trim($allDataInSheet[$i]["B"]);
     //$hname = mb_detect_encoding($email);

     if($name) {
         mysql_set_charset('utf8');
     $insertTable= mysql_query("insert into data (name, email) 
    values('".$name."', 
    '".$email."')");


    $msg = 'Record has been added. <div style="Padding:20px 0 0 0;"><a 
    href="">Go 
    Back to tutorial</a></div>';
    } else {
    $msg = 'Record already exist. <div style="Padding:20px 0 0 0;"><a href="">Go 
     Back to tutorial</a></div>';
    }
    }
    echo "<div style='font: bold 18px arial,verdana;padding: 45px 0 0 
    500px;'>".$msg."</div>";


    ?>
    <body>
   </html>

1 Answers1

0

What I think is Excel fonts or any other font can not be stored in db. You only can store data only

Vijay Maurya
  • 99
  • 1
  • 6