Home > Backend Development > PHP Problem > How to solve the php odbc garbled problem

How to solve the php odbc garbled problem

藏色散人
Release: 2023-03-03 12:16:02
Original
3670 people have browsed it

php odbc garbled solution: first open the corresponding PHP code file; then modify the code to "@header("Content-Type:text/html;charset=GB18030");"; finally save and run PHP file is enough.

How to solve the php odbc garbled problem

Recommended: "PHP Tutorial"

Specific questions:

php uses ODBC to connect to sql server and the output is garbled! ! !

<?php
@header("Content-Type:text/html;charset=UTF-8");
$conn=odbc_connect(&#39;SQL&#39;,&#39;sa&#39;,&#39;sa&#39;);
if(!$conn)
echo "Fail";
$sql="select * from GoodSpec where GoodsNO=&#39;3316&#39;";
$result_id=odbc_do($conn, $sql);
$idno = odbc_result($result_id,2);
echo $idno; //这里输出乱码
odbc_close($conn);
?>
Copy after login

Solution:

@header("Content-Type:text/html;charset=GB18030");

Change to this OK.

or

The above is the detailed content of How to solve the php odbc garbled problem. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template