I am trying to SELECT data from 1 database and insert into another, but I have problem in INSERT.
I get this error PHP Fatal error: Uncaught Error: Call to a member function execute() on boolean
when I run my code.
MY CODE
<?php
include 'db_acc.php';
include 'db_sat.php';
$sql = "SELECT created_at,updated_at
FROM satellite1.show_activity";
$result=$conn1->query($sql);
while($row = $result->fetch_assoc()) {
echo "$row[updated_at]"; // I can get the value
$sql2 = "INSERT INTO analysis_account.currency SET
id=0,
currency_code='MYR',
currency_rate= 3.500,
currency_unit= 100,
base_currency= 1,
created_by= 2,
updated_by= 2,
created_at= '2021-05-17 14:10:32',
updated_at = ".$row["updated_at"].", // But I cant insert the value
curr_hidden = 1 ";
$query=$conn2->query($sql2);
}
$conn2->close();
?>
The problem is I can get the value of $row[updated_at]
but I cant insert it into other database table, the connection is no problem because if I change $row[updated_at]
into '2021-05-17 14:10:32'
then the insert statement work.
I checked my connection, column names, symbols there are no problem of them. I really dont know what to do to solve the error.