select_db("books"); $query1 = "insert into books values('123-45"/> select_db("books"); $query1 = "insert into books values('123-45">
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插入不进去数据...