Home > Backend Development > PHP Tutorial > php用sqlite存进去的是乱码

php用sqlite存进去的是乱码

WBOY
Release: 2016-06-23 14:19:22
Original
1075 people have browsed it

我php写了一个插入语句,里面包含中文,后来发现存进去的是乱码,
后面我用查询语句按我中文关键字查不出来
我在插入语句要怎么设置编码
if ($_POST[submit])
 {

$db=sqlite_open("user.db");
//$sql="create table user (id int,name varchar(20),password varchar(20))";
$sql="select * from user where name=$_POST[username] and password=$_POST[password]";
//sqlite_query("set names 'GBK'");
//$sqls="select * from user";
//$queryi=sqlite_query($db,$sqli);
$query=sqlite_query($db,$sql);


回复讨论(解决方案)

设置数据库 连接 编码  跟HTML 页面编码一致而且 PHP页面 编码也要一致

sqlite 不存在编码问题!
存进去什么,读出来的就是什么

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