简体   繁体   English

未声明HTML文档

[英]HTML document was not declared

This is about retriving the data in form of CSV from Mysql Table : - 这是关于从Mysql表中以CSV格式检索数据:-

Code , I tried :- 代码,我试过了:

<?php
// mysql database connection details
    $host = "localhost";
    $username = "root";
    $password = "hello";
    $dbname = "mysql2csv";

// open connection to mysql database
    $connection = mysqli_connect($host, $username, $password, $dbname) or     die("Connection Error " . mysqli_error($connection));

// fetch mysql table rows
    $sql = "select * from tbl_books";
    $result = mysqli_query($connection, $sql) or die("Selection Error " .     mysqli_error($connection));

    $fp = fopen('books.csv', 'w');

    while($row = mysqli_fetch_assoc($result))
{
        fputcsv($fp, $row);
}

    fclose($fp);

//close the db connection
    mysqli_close($connection);

?> ?>

Errors Obtained... 发生错误...

04:12:27.093 The character encoding of the HTML document was not declared. 04:12:27.093未声明HTML文档的字符编码。 The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. 如果文档包含来自US-ASCII范围之外的字符,则在某些浏览器配置中,文档将呈现乱码。 The character encoding of the page must be declared in the document or in the transfer protocol.1 mysql2csv.php. 页面的字符编码必须在文档或传输协议中声明。1mysql2csv.php。

your help will be appreciated ... 您的帮助将不胜感激...

Add those lines to your html header 将这些行添加到您的html标头中

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

Edit: If you are using PHP file: 编辑:如果您正在使用PHP文件:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM