PHP代码,数据增加的问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 06:55:02
<?php

$isbn=$_POST['isbn'];
$author=$_POST['author'];
$title=$_POST['title'];
$price=$_POST['price'];

if (!$isbn || !$author || !$title || !$price)
{
echo 'You have not entered all the required details.<br />'
.'Please go back and try again.';
exit;
}
if(!get_magic_quotes_gpc())
{
$isbn=addslashes($isbn);
$author=addslashes($author);
$title=addslashes($title);
$price=doubleval($price);
}

@ $db=new mysqli('localhost','root','89233182','books');

if(mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}

$query ="insert into books values('$isbn','$author','$title','$price')";
$result=$db->query($query);

if($result)

ec

有SQL错误提示吗?
把类中SQL错误提示打开看下.

我觉得主要问题出在$query ="insert into books values('$isbn','$author','$title','$price')"; 这句

数据类型,数据个数,数据长度.你等核对下.或者把错误提示发出来我再看下

用phpx上的例子就可以