1
I have a database Mysql and I am trying to import the data from a table that the customer passed to my default table. Using the script below, no error appears, however import is not done, table immovable is still empty:
$sql_antigo = "SELECT * FROM mytable ORDER BY id_imovel ASC";
$exe_antigo = mysqli_query($conection, $sql_antigo);
while($row=mysqli_fetch_assoc($exe_antigo)){
$id = $row['id_imovel'];
$codigo = $row['codigo'];
$controle = round(microtime(true) * 1000);
$sql_novo = "INSERT INTO imoveis (id,cod_int,controle) VALUES ('$id','$codigo','$controle')";
$exe_novo = mysqli_query($conection, $sql_novo);
echo 'Dados do imóvel ' .$id. ' importados com sucesso!<br>';
}
In the echo, appears the phrase stating that all data has been imported.
The
echo
, as it is, it will be displayed regardless of the table having, or not, recorded the data. Use themysqli_error
to check for errors. Also check the value of$exe_antigo
is different fromfalse
– Valdeir Psr
There may be some errors in the Insert procedure. How is your table created? Does the ID field happen to be auto_increment? If yes, you do not need to specify. .
– Marcelo Macedo