0
I have my employee delete but gives these mistakes:
"Undefined index: id in C: wamp www Sitephp base excluirFunctioning.php on line 6"
"PDO::exec() expects Parameter 1 to be string, Object Given in C: wamp www Sitephp base excluirFunctional.php on line 8".
Follows my code:
require_once '../base/conexao.php';
$id = $_GET['id'];
$delete = $PDO->query("DELETE FROM funcionario WHERE id = '$id' ");
$PDO->exec($delete);
if ($id){
echo "<script>alert('Registro de Funcionario deletado');location.href = 'listarFuncionario.php'; </script>";
}else{
echo "<script>alert('Ocorreu um erro no processo');location.href = 'listarFuncionario.php'; </script>";
}
function excluir(id){
if(confirm("Deseja excluir o registro?")){
location.href = 'excluirFuncionario.php';
}
}
<?php while($funcionario = $rs->fetch(PDO::FETCH_ASSOC)) { ?>
<tr>
<td align="center"><a href="excluirFuncionario.php" onkeyup="excluir(id)" onclick="excluir(<?php echo $funcionario['id'];?>)"><img src="../imagens/delete.png"></a></td>
</tr>
<?php }?>
</tbody>
From what I understand, there is no index
id
inside the$_GET
, check if you are passing correctly!– JuniorNunes
I’m seeing if it’s a connection problem, because it’s not really looking for the ID
– Ruan Rodrigues