DMW 0 Denunciar post Postado Agosto 26, 2010 E ae galera beleza ??? Bom galera eu so iniciante em PHP O.O e estou tentando fazer um cadastro mas esta dando esse erro: Query invalida! Unknown column 'AAA' in 'field list'. E eu nao sei onde pode estar errado. Alguem pode me ajudar ??? Grato..... agencia.class.php: <?php class Agencia{ public $nome; public $responsavel; function getNome(){ return $this->nome; } function setNome($nome){ $this->nome = $nome; } function getResp(){ return $this->responsavel; } function setResp($responsavel){ $this->responsavel = $responsavel; } } ?> form_cadastro: <?php include("conexao.php"); include("agencia.class.php"); if(isset($_POST["btncad"])){ $nome = $_POST["txtnome"]; $resp = $_POST["txtresp"]; $agencia = new Agencia; $agencia->setNome($_POST["txtnome"]); $agencia->setResp($_POST["txtresp"]); function Cadastra($agencia){ $cad = "INSERT INTO tab_agencia_comercial(nome,responsavel)VALUES(".$agencia->getNome().",".$agencia->getResp().")"; $result=mysql_query($cad); if (!$result) { $message = '<br><br>Query invalida! ' . mysql_error() . "\n"; } else $message = '<br><br><b>Query completa:</b> ' . $cad; die($message); }//fim da function Cadastra($agencia); } ?> <!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>.:: Cadastro de Agência</title> </head> <body> <form name="form1" id="form1" method="post"> <fieldset> <legend>Dados da Agência</legend> <br /> Nome: <input type="text" name="txtnome" id="txtnome" size="50"/><br /><br /> Responsavel: <input type="text" name="txtresp" id="txtresp" size="40"/><br /><br /> Telefone: <input type="text" name="txttel" id="txttel" size="40"/><br /><br /> E-Mail: <input type="text" name="txtemail" id="txtemail" size="30"/><br /><br /> Endereço: <input type="text" name="txtend" id="txtend" size="50"/><br /><br /> Bairro: <input type="text" name="txtbairro" id="txtbairro" size="40"/><br /><br /> Cidade: <input type="text" name="txtcid" id="txtcid" size="40"/><br /><br /> C.E.P: <input type="text" name="txtcep" id="txtcep" size="20"/><br /><br /> Site: <input type="text" name="txtsite" id="txtsite" size="40"/><br /><br /> Status:<br /> <textarea name="txtstatus" cols="50" rows="10" id="txtstatus"></textarea> <br /><br /><br /> <input type="submit" name="btncad" id="btncad" value="Cadastrar"/> </fieldset> </form> </body> </html> Compartilhar este post Link para o post Compartilhar em outros sites
gremio10 14 Denunciar post Postado Agosto 26, 2010 Tu entendeu qual a mensagem do erro ? Compartilhar este post Link para o post Compartilhar em outros sites
DMW 0 Denunciar post Postado Agosto 26, 2010 Ele ta falando q a coluna nao existe. A tabela eu fiz assim: CAMPO TIPO NULO id int(11) Nao nome varchar(200) Sim responsavel varchar(100) Sim Compartilhar este post Link para o post Compartilhar em outros sites
_neto_ 0 Denunciar post Postado Agosto 26, 2010 Eu acho que você só esqueceu das aspas simples nos valores varchar do insert. Compartilhar este post Link para o post Compartilhar em outros sites
DMW 0 Denunciar post Postado Agosto 26, 2010 Vlw _neto_ foi isso mesmo que você falo !!! Mt obrigado !!! Compartilhar este post Link para o post Compartilhar em outros sites