0
I’m trying to record some information on Mysql through a Array
obitda of an external execution, below the code I am using:
$licencas = exec(escapeshellcmd($comando), $output);
reset($output);
while (list(,$line) = each($output)){
echo $line, "<BR>\n";
$sql= mysqli_query ($conexao,"INSERT INTO licenca (cnpj,dados, data) VALUES ('$cnpj', '$line', '$data')");
}
It is working, but when it stores in the table, it stops recording some lines that were obtained, in echo appears all lines as I need.
Who can help me.
Thank you very much.
Insert a
mysqli_error
and see if anything returns.$sql= mysqli_query ($conexao,"INSERT INTO licenca (cnpj,dados, data) VALUES ('$cnpj', '$line', '$data')") or die(mysqli_error($conexao);
– Pedro Augusto
I added, presented this message! You have an error in your SQL syntax; check the manual that Corresponds to your Mariadb server version for the right syntax to use near’s : 1', '2019-02-08 08:24')' at line 1
– Moises Pequeno
Print the query you are running, the message says you have some syntax error
– Pedro Augusto
Hi Pedro, I searched here and I managed to solve it this way: $licencas = exec(escapeshellcmd($command), $output); reset($output); while (list(,$line) = each($output)){ 
echo $line, "<BR>\n"; $stmt = mysqli_prepare($conexao, "INSERT INTO licenca (cnpj,dados, data) VALUES(?,?,?)");
mysqli_stmt_bind_param($stmt, 'sss', $cnpj, $line, $data);
mysqli_stmt_execute($stmt);
} Será assim o melhor jeito?
– Moises Pequeno