I have a SQL table called books
which has columns Name, ID, Author, Language, Pages, Genres, and Status
. Now, I want to copy data from this table's Name, ID, Author, and Status
columns to another table called log
which has columns Name, ID, Author, Status and TimeStamp.
.
I'm getting the TimeStamp
from the PHP code which I want to send through the INSERT statement.
Here's the code I've been trying:
$queryBook = $_GET['ID'];
$currentDate = date('d-m-Y H:i:s');
$stmt4 = $conn -> prepare("INSERT INTO log (Name, ID, Author, Status) SELECT (Name, ID, Author, Status), ? FROM books WHERE ID = '$queryBook'");
$stmt4 -> bind_param('s', $currentDate);
$stmt4 -> execute();
I tried this code as well:
$stmt4 = $conn -> prepare("INSERT INTO log * SELECT Name, ID, Author, Status FROM books WHERE ID = '$queryBook'");
$stmt4 -> execute();
I'm getting this error:
Fatal error: Uncaught Error: Call to a member function execute() on boolean