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

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

WBOY
Release: 2016-06-06 20:36:34
Original
1055 people have browsed it

<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>
Copy after login
Copy after login

回复内容:

<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>
Copy after login
Copy after login

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

INSERT INTO tb () VALUES ...

是 values 而不是 value

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

Related labels:
php
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