select_db("books"); $query1 = "insert into books values('123-45"/> select_db("books"); $query1 = "insert into books values('123-45">
Home > Backend Development > PHP Tutorial > php没法将数据插入mysql

php没法将数据插入mysql

WBOY
Release: 2016-06-13 13:00:48
Original
1271 people have browsed it

php无法将数据插入mysql
源码:
$db =new  mysqli("localhost","root","5832528");
$db->select_db("books");
$query1 = "insert into books values('123-457','zhp','C++',56)";
if(mysqli_connect_errno()){
echo '连接错误';
exit;
}
$result = $db->query($query1);
if($result)
echo $db->affected_rows.' book inserted into database';
else
echo "Error";
$db->close();

在phpmyadmin执行查询语句没问题,数据库也可以连接上去,执行查询什么的也没问题。就谁无法将数据插入mysql了
------解决方案--------------------
将这句话,insert into books values('123-457','zhp','C++',56),直接插入数据库,看是否报错?有可能本身这句话就是有错误的,所以导致你php插入不进去数据...

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