0
I need to insert in the variable database that are in a php array, I wrote the cogido:
for ($i=1; $i <= 20 ; $i++) {
$sqlp= "INSERT INTO pergunta$i (pergunta, opcao1, valor1, opcao2, valor2, opcao3, valor3, opcao4, valor4, opcao5, valor5, opcao6, valor6, opcao7, valor8, opcao2, valor8) VALUES (`$tabela[$i][1]`,`$tabela[$i][2]`,`$tabela[$i][3]`,`$tabela[$i][4]`,`$tabela[$i][5]`,`$tabela[$i][6]`,`$tabela[$i][7]`,`$tabela[$i][8]`,`$tabela[$i][9]`,`$tabela[$i][10]`,`$tabela[$i][11]`,`$tabela[$i][12]`,`$tabela[$i][13]`,`$tabela[$i][14]`,`$tabela[$i][15]`,`$tabela[$i][16]`,`$tabela[$i][17]`,)";
$salvar= mysqli_query($conexao, $sqlp);
}
when executed, the browser returns array to string conversion error, as I can resolve?
Because then, if the error is in converting array to string vc should post that part of the code as well
– user60252
error says conversation is on this line
– Marcelo Nassar
table name question$i ?? 20 tables?
– user60252
yes, there are 20 tables with names: question1, question2, question3... up to 20, so the idea is to use the for to vary between these tables
– Marcelo Nassar
right, but there must be some invalid value in the conversion. I only see there
– user60252
invalid value in what sense?
– Marcelo Nassar
The arrays in php, when inside double quotes, concatenates as follows:"array: {$array['key']}" where the keys indicate that inside is an array.
– Bruno Folle