Trying create select query also inserts record into database but getting an error
I am trying to create a select query that inserts a record into one table from another table if it matches the ID added by a user in a form field. The first table; 'customercontacts' holds all the client info. I have duplicated the structure and created a new table; 'customercontactsOverwritten' - I removed the primary index and AUTO_INCREMENT from the RefID field in the new table.
This is my code:
<?php
if ((isset($_POST["AddBooking"]) || isset($_POST["AddBooking_x"])) && $_POST["ClientID"] !='') {
$clients = new WA_MySQLi_RS("clients",$bookings,0);
$clients->setQuery("INSERT INTO customercontactsOverwritten (select * from customercontacts WHERE RefID =?)");
$clients->bindParam("i", "".$_POST['ClientID'] ."", "-1"); //colname
$clients->execute();
}
?>
The query does execute and it inserts the record into the table 'customercontactsOverwritten', but it throws this error on the page:
Fatal error: Uncaught Error: Call to a member function fetch_fields() on bool in /home/holidayretailers/public_html/webassist/mysqli/rsobj.php:254 Stack trace: #0 /home/holidayretailers/public_html/manager/bookingform-Update2.php(111): WA_MySQLi_RS->execute() #1 {main} thrown in /home/holidayretailers/public_html/webassist/mysqli/rsobj.php on line 254


