2
I am with this small problem, no matter what I do not right, always keeps giving "invalid query", someone could help me?
<?php
include('conexao.php');
include('fecha_conexao.php');
function inserir($coluna,$valor,$tabela){
error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);
//perguntando se é um array
if((is_array($coluna)) and (is_array($valor))){
//perguntando se tem o mesmo número de elementos
if(count($coluna) == count($valor)){
//query de inserção no banco
$inserir = "INSERT INTO {$tabela}(".implode(', ',$coluna).") VALUES('".implode('\', \'',$valor)."')";
}else{
return false;
}
}else{
$inserir = "INSERT INTO {$tabela}({$coluna}) VALUES ('{$valor}')";
}
if($connect =connect()){
if(mysql_query($inserir,$connect)){
fechaConexao($connect);
echo "Dados inseridos com sucesso";
return true;
}else{
echo"Query Inválida!";
return false;
}
}else{
return false;
}
}
?>
Gives a
echo $inserir
which is already a start.– rray
Please place the code as text in the body of the question.
– eduardosouza
I gave an echo on the $insert and nothing came up
– Dennis Gonçalves
do not use a include to close a connection. It is a waste of memory. Close the connection, of course, with a
mysqli_close($conn);
– djva