olá pessoal, não achei no forum por isso resolvir postar. Estou quebrando a cabeça tentando achar o erro do meus PHPs Form, conexao e funcao( de um formuário q desejo cadastrar e editar: Obs: erro está na linha 11 e 52 do php FORM Form 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5<title>Untitled Document</title>
6</head>
7
8<body>
9<?
10include "conexao.php";
11if($_GET['funcao'] != "editar"){
12?>
13<form id="form1" name="form1" method="post" action="funcao.php?funcao=gravar">
14 <table width="305" border="0"> <tr>
15
16 <th width="53" scope="row">Nome:</th>
17 <td width="236"><label>
18 <input name="nome" type="text" id="nome" size="40" />
19 </label></td>
20 </tr>
21 <tr>
22 <th scope="row">Email:</th>
23 <td><label>
24 <input name="email" type="text" id="email" size="40" />
25 </label></td>
26 </tr>
27 <tr>
28 <th scope="row">Cidade:</th>
29 <td><label>
30 <input name="cidade" type="text" id="cidade" size="40" />
31 </label></td>
32 </tr>
33 <tr>
34 <th scope="row">Mensagem</th>
35 <td><label>
36 <textarea name="mensagem" id="mensagem" cols="45" rows="5"></textarea>
37 </label></td>
38 </tr>
39 <tr>
40 <th height="59" scope="row"> </th>
41 <td><label> </label><div align="right">
42 <input type="submit" name="button" id="button" value="Cadastrar" />
43 </div></td>
44 </tr><br />
45 <br />
46 </table>
47</form>
48<?
49}
50?>
51<?
52if($_GET['funcao'] == "editar"){
53$id = $_GET['id'];
54$sql_update = mysql_query("SELECT * FROM aprendendo WHERE id = '$id' ");
55while($linha = mysql_fetch_array($sql_update)){
56 $nome = $linha['nome'];
57 $email = $linha['email'];
$cidade = $linha['cidade'];
$mensagem = $linha['mensagem'];
}
?>
<form id="form1" name="form1" method="post" action="funcao.php?funcao=editar&id=<? echo $id ?>">
<table width="305" border="0"> <tr>
<th width="53" scope="row">Nome:</th>
<td width="236"><label>
<input name="nome" type="text" id="nome" size="40" value=<? echo $nome ?> />
</label></td>
</tr>
<tr>
<th scope="row">Email:</th>
<td><label>
<input name="email" type="text" id="email" size="40" value=<? echo $email ?> />
</label></td>
</tr>
<tr>
<th scope="row">Cidade:</th>
<td><label>
<input name="cidade" type="text" id="cidade" size="40" value=<? echo $cidade ?>/>
</label></td>
</tr>
<tr>
<th scope="row">Mensagem</th>
<td><label>
<textarea name="mensagem" id="mensagem" cols="45" rows="5"><? echo $nome ?></textarea>
</label></td>
</tr>
<tr>
<th height="59" scope="row"> </th>
<td><label> </label><div align="right">
<input type="submit" name="button" id="button" value="Alterar" />
</div></td>
</tr><br />
<br />
</table>
</form>
<?
}
?>
<table width="954" border="0">
<tr>
<th width="717" align="left" bgcolor="#BBBBBB" scope="row"><strong>Nome</strong></div>
</strong></th>
<td width="82" align="center" bgcolor="#BBBBBB"><strong><strong>Editar</strong></td>
<td width="83" align="center" bgcolor="#BBBBBB"><strong><strong>Remover</strong></td>
</tr>
<?
$sql_visualizar = mysql_query("SELECT * FROM aprendendo ORDER BY nome");
while($linha = mysql_fetch_array($sql_visualizar)){
$pega_nome = $linha['nome'];
$id = $linha['id'];
?>
<tr>
<td><? echo $pega_nome?></td>
<td align="center"><a href="form.php?funcao=editar&id=<? echo $id ?>">EDITAR</a></td>
<td align="center"><a href="funcao2.php?funcao=excluir&id=<? echo $id ?>">EXLUIR</a></td>
</tr>
<?
}
?>
</table>
</body>
</html>
conexao
<?
$db = mysql_connect("localhost","root","");
$banco = mysql_select_db("tabela",$db);
?>
funcao
<?
include "conexao.php";
$nome = $_POST['nome'];
$email = $_POST['email'];
$cidade = $_POST['cidade'];
$mensagem = $_POST['mensagem'];
//**********************************************************************
if($_GET['funcao'] == "gravar"){
$sql = mysql_query("INSERT INTO aprendendo (nome,email,cidade,mensagem) value ('$nome','$email','$cidade','$mensagem')");
header('Location:form.php');
}
//**********************************************************************
if($_GET['funcao'] == "editar"){
$id = $_GET['id'];
$sql_alterar = mysql_query("UPDATE aprendendo SET nome='$nome',email='$email',cidade='$cidade',mensagem'$mensagem'id = '$id' ");
header('Location:form.php');
}
?> aqui está o erro: uso o programa WAMPSERVER, obrigado e agraços.