altera nao tah chamando o id no update
Olá, eu to fazendo um CRUD e na parte do altera tah dando esse erro:
**Erro ao executar a query:** UPDATE tarefas SET titulo = 'ndghn', descricao = 'dnhn' WHERE id = -> You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
e dizendo: undefined index: id;
nao to conseguindo resolver e provavelmente é algo simples, mas sou iniciante.
quem poder me ajuda eu agradeco.
Segue o codigo:
<?php
header ('Content-type: text/html; charset=ISO-8859-1');
//////////////////////
require("conn.class.php");
require("menu.class.php");
require("tarefa.class.php");
$obj_menu = new Menu;
$menu = $obj_menu->monta();
////////////////////////////////
$id = $_POST['id'];
$titulo = $_POST['titulo'];
$descricao = $_POST['descricao'];
$tarefa = new Tarefas;
$query = "UPDATE tarefas SET titulo = '".$titulo."', descricao = '".$descricao."' WHERE id = ".$id;
$sql = $tarefa->altera($query);
if($sql){
$texto = "Tarefa alterada.";
}else{
$texto = "Erro ao tentar alterar Tarefa.";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title>Gerenciador de Tarefas</title>
</head>
<body>
<h3 align="center">Gerenciador de Tarefas</h3>
<hr /><!--MENU-->
<p align="center"><?=$menu?></p>
<hr /><!--FIM MENU-->
<!------------------->
<p align="center"><?=$texto?></p>
</body>
</html>Discussão (1)
Carregando comentários...