Home  >  Article  >  Backend Development  >  PHP表单提交到数据库并查询 插入出错,

PHP表单提交到数据库并查询 插入出错,

WBOY
WBOYOriginal
2016-06-06 20:36:341029browse

<code><?php echo $_POST['bookname']."<br/>";
echo $_POST['price']."<br>";
echo $_POST['type']."<br>";

$bookname = $_POST['bookname'];
$price = $_POST['price'];
$type1 = $_POST['type'];
require_once 'conn.php';
$result = mysql_query("insert into book (`bookname`,`price`,`time`) value ('$bookname','$price','$type1')");
dump($result);
// if($result){
// echo "添加成功";
// }
// else{
//  echo '添加失败';
// }
?>
</code>

回复内容:

<code><?php echo $_POST['bookname']."<br/>";
echo $_POST['price']."<br>";
echo $_POST['type']."<br>";

$bookname = $_POST['bookname'];
$price = $_POST['price'];
$type1 = $_POST['type'];
require_once 'conn.php';
$result = mysql_query("insert into book (`bookname`,`price`,`time`) value ('$bookname','$price','$type1')");
dump($result);
// if($result){
// echo "添加成功";
// }
// else{
//  echo '添加失败';
// }
?>
</code>

建议你看下 INSERT INTO 的正确写法。。

INSERT INTO tb () VALUES ...

是 values 而不是 value

http://database.51cto.com/art/201005/202402.htm

Statement:
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