简体   繁体   中英

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. I have read the documentation for using sqlite3 with PHP, and have tried to follow it carefully. Here is the specific syntax on how to do insertion queries in PHP for sqlite3: https://www.php.net/manual/en/sqlite3.exec.php

Here is some insertion code I am trying to execute. Each variable value in the query is gathered from an html form.

$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.

Finally found the problem. The form's submit tag in the html had the value "Submit" instead of "Submit Action".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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