Home > Backend Development > PHP Tutorial > #生手来袭# 依旧关于mysql_query()函数

#生手来袭# 依旧关于mysql_query()函数

WBOY
Release: 2016-06-13 13:15:58
Original
913 people have browsed it

#新手来袭# 依旧关于mysql_query()函数
$con=mysql_connect("localhost","root","root");
  mysql_select_db("findbottle",$con);

  $sql = "INSERT INTO find (findbottle_name,findbottle_sex,findbottle_email,
  findbottle_time,findbottle_address,findbottle_DorL,findbottle_other) VALUES ('$findbottle_name','$findbottle_sex','$findbottle_email',
  '$findbottle_time','$findbottle_address','$findbottle_DorL','$findbottle_other')";

  $result=mysql_query($sql,$con)
  or die('Error query database');

-----------------------------------------

1.为什么这个函数传入数据库的中文是乱码?其他的都是正常的,
2.为什么我使用函数传入数据库之后,再改成表对象传入数据库就不行了,提示bool(false);

------解决方案--------------------
1. 在链接数据库后根据编码做一个设定 mysql_query("SET NAMES GBK"); //gbk gb2312 utf8
2.什么叫改成表对象传入?


------解决方案--------------------
$mysqli->set_charset("utf8") ; //插入前加上这句

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