Andreatti 0 Denunciar post Postado Agosto 2, 2010 Aew galera.. to começando a aprender PHP e to fazendo uns testes ake... criei uma agenda(lol)... Bom... pra rodar o PHP aki em casa na minha maquina... eu utilizo o easyPHP, criei um codigo de inserçao e um para exibir, porem esta dando um erro na hora da consulta no BD. Dei uma olhada aqui e nao cnsegui achar o erro. Alguem poderia me da uma dica? vlw. Segue o Codigo: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <?php mysql_connect('localhost', 'root', ''); mysql_select_db('agenda'); ?> <body> <form action="agenda.php" method="POST" name="agenda"> <table width="213" border="0" align="center"> <tr> <td><font color=#CCCCCC><strong>Nome:</strong></font></td> <td width="159"><input name="edtNome" type="text" id="edtNome" /></td> </tr> <tr> <td><font color=#CCCCCC><strong>Telefone:</strong></font></td> <td><input name="edtTel" type="text" id="edtTel" /></td> </tr> </table> <input name="Enviar" type="submit" id="Enviar" value="Enviar" /> </form> <?php if (isset ($_POST["edtNome"])){ $inome = $_POST['edtNome']; $itelefone = $_POST['edtTel']; $comando = "INSERT INTO contatos (nome, telefone) VALUES ('$inome', '$itelefone')"; $resultado = mysql_query( $comando ) or die (mysql_error()); } ?> <p>Contatos:</p> <?php $sql = "SELECT * FROM agenda "; $resultado = mysql_query( $sql ) or die ("Não foi possível realizar a CONSULTA: $sql"); while ($linha = mysql_fetch_assoc($resultado)) { $nome = $linha['nome']; $telefone = $linha['telefone']; echo "<font color=#CCCCCC><strong>Nome:</strong> $nome </font><br>"; echo "<br>"; } ?> </body> </html> Vo continuar olhando aki. Se eu conseguir descobrir eu aviso. Espero que me ajudem. Vlws Compartilhar este post Link para o post Compartilhar em outros sites
Andreatti 0 Denunciar post Postado Agosto 2, 2010 Sorry... falta de atençao minhna... troquei o nome do banco pelo da tabela(ou vice versa) Compartilhar este post Link para o post Compartilhar em outros sites