简体   繁体   English

无法使用 PHP 将数据插入 sqlite3 数据库

[英]Unable to insert data into sqlite3 database using PHP

I've been trying to get my PHP code to insert data into my sqlite3 database.我一直在尝试让我的 PHP 代码将数据插入到我的 sqlite3 数据库中。 I have read the documentation for using sqlite3 with PHP, and have tried to follow it carefully.我已经阅读了将 sqlite3 与 PHP 一起使用的文档,并尝试仔细遵循它。 Here is the specific syntax on how to do insertion queries in PHP for sqlite3: https://www.php.net/manual/en/sqlite3.exec.php以下是关于如何在 PHP 中为 sqlite3 执行插入查询的具体语法

Here is some insertion code I am trying to execute.这是我正在尝试执行的一些插入代码。 Each variable value in the query is gathered from an html form.查询中的每个变量值都是从 html 表单中收集的。

$db->exec("
   INSERT INTO BOOK(Title,Author,Genre,ISBN_number,Age_rating,Language,Book_review,Price)
   VALUES (
'$Btitle', '$BAuthor', '$BGenre', '$BISBN', '$age', '$lan', '$bookRev', '$pr')
");

This code does not throw any errors.此代码不会引发任何错误。 However, when I do a selection query through PHP to display the books, the entry from this line of code is not in the table.但是,当我通过 PHP 进行选择查询以显示书籍时,这行代码中的条目不在表中。

Finally found the problem.终于发现问题了。 The form's submit tag in the html had the value "Submit" instead of "Submit Action". html 中的表单提交标签的值是“提交”而不是“提交操作”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM