Ir para conteúdo
Fórum Script Brasil
  • 0

[resolvido] Não resgata os valores no UPDATE


Gustavo Moraes

Pergunta

Pessoal, tenho um sistema de imobiliaria, q blza, cadastro imoveis , apaga, mas não atualiza!! e pior q aparentemente está tudo correto, mas quando mando atualiza com os dados novos, ele atualiza deixando TODOS os campos em branco, é tipo como se ele não tivesse conseguindo pegar o valor das coisas novas q digitei ou algo do tipo, alguém tem alguma ideia? vou postar o codigo da pagina para verem:

altera2.asp

<!--#include file="../includes/config.asp"-->
<!--#include file="../includes/abrebanco2.asp"-->
<!--#include file="travar.asp"-->
<% Call abreimo %>
<%
var_id = Request.QueryString("id")
var_categoria = Request.QueryString("categoria")

sql = "SELECT * FROM categorias"
sql2 = "SELECT * FROM tipos"
sql3 = "SELECT * FROM cidades"
sql4 = "SELECT * FROM imoveis WHERE id LIKE '"& var_id &"' AND categoria = '"& var_categoria &"'"
Set exe = banco.execute(sql)
Set exe2 = banco.execute(sql2)
Set exe3 = banco.execute(sql3)
Set exe4 = banco.execute(sql4)
%>
<title><%=titulo%></title>
<body bgcolor="<%=fundo%>" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<link href="<%=local%>includes/styles/link.css" rel="stylesheet" type="text/css">
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <!--#include file="../includes/barraadm.asp"-->
    </td>
  </tr>
  <tr>
    <td height="0"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="159" valign="top">
            <!--#include file="../includes/menuesqadm.asp" -->
          </td>
          <td width="60%" height="738" valign="top"><table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td height="0"><form action="alterado2.asp?categoria=<%=exe4("categoria")%>&id=<%=exe4("id")%>" method="post" enctype="multipart/form-data">
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr> 
                        <td colspan="2">&nbsp;</td>
                      </tr>
                      <tr> 
                        <td colspan="2"><%=fonte02%><strong>Atualizar im&oacute;vel</strong></td>
                      </tr>
                      <tr> 
                        <td colspan="2">&nbsp;</td>
                      </tr>
                      <tr> 
                        <td colspan="2"><div align="center"><font color="#FF0000" size="1" face="verdana">*Campos 
                            obrigat&oacute;rios</font></div></td>
                      </tr>
                      <tr bgcolor="<%=tit_fundo%>"> 
                        <td colspan="2"><div align="center"><%=fonte04%><strong>Dados</strong></div></td>
                      </tr>
                      <tr> 
                        <td width="27%"><%=fonte02%>Categoria:*</td>
                        <td width="73%"><select name="f_categoria" size="1" id="f_categoria">
                            <option selected><%=exe4("categoria")%></option>
                            <%WHILE NOT exe.eof
                        Response.Write "<option>" & exe("categoria") & "</option>"
                        exe.MOVENEXT : Wend%>
                          </select></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Tipo:*</td>
                        <td><select name="f_tipo" size="1" id="f_tipo">
                            <option selected><%=exe4("tipo")%></option>
                            <%WHILE NOT exe2.eof
                        Response.Write "<option>" & exe2("tipo") & "</option>"
                        exe2.MOVENEXT : Wend%>
                          </select></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Local:*</td>
                        <td><select name="f_local" size="1" id="f_local">
                            <option selected><%=exe4("cidade")%></option>
                            <%WHILE NOT exe3.eof
                        Response.Write "<option>" & exe3("cidade") & "</option>"
                        exe3.MOVENEXT : Wend%>
                          </select></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Endere&ccedil;o:*</td>
                        <td><textarea name="f_endereco" id="f_endereco"><%=exe4("endereco")%></textarea></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>N&uacute;mero:</td>
                        <td><input name="f_numero" type="text" id="f_numero" value="<%=exe4("numero")%>"></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>&Aacute;rea:*</td>
                        <td><input name="f_area" type="text" id="f_area" value="<%=exe4("area")%>"></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Dormit&oacute;rios:*</td>
                        <td><input name="f_dormitorios" type="text" id="f_dormitorios" value="<%=exe4("dormitorio")%>"></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Sendo Su&iacute;tes:</td>
                        <td><input name="f_suites" type="text" id="f_suites" value="<%=exe4("suite")%>"></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Pre&ccedil;o:*</td>
                        <td><input name="f_preco" type="text" id="f_preco" value="<%=exe4("preço")%>"></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Condi&ccedil;&otilde;es de Pagamento:</td>
                        <td><textarea name="f_condicoes" id="f_condicoes"><%=exe4("cond_pagamento")%></textarea></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Descri&ccedil;&atilde;o:*</td>
                        <td><textarea name="f_descricao" id="f_descricao"><%=exe4("descricao")%></textarea></td>
                      </tr>
                      <tr> 
                        <td><%=fonte02%>Texto em destaque:*</td>
                        <td><textarea name="f_destaque" id="f_destaque"><%=exe4("desc_destaque")%></textarea></td>
                      </tr>
                      <tr> 
                        <td colspan="2">&nbsp;</td>
                      </tr>
                      <tr> 
                        <td colspan="2"><div align="center"> 
                            <input name="Limpar" type="reset" id="Limpar" value="Limpar">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                            <input name="Inserir" type="submit" id="Inserir" value="Atualizar">
                          </div></td>
                      </tr>
                      <tr> 
                        <td colspan="2">&nbsp;</td>
                      </tr>
                      <tr> 
                        <td colspan="2"><div align="center"><%=fonte01%><a href="imoveis.asp">Voltar</a></div></td>
                      </tr>
                      <tr> 
                        <td colspan="2">&nbsp;</td>
                      </tr>
                    </table>
                  </form></td>
              </tr>
            </table></td>
          <td width="154" valign="top"><!--#include file="../includes/menudiradm.asp" --></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td><!--#include file="../includes/rodapeadm.asp"--></td>
  </tr>
</table>
</body>
<% call fechaimo %>
Agora a pagina q insere os dados do formulario no BD
<!--#include file="../includes/config.asp"-->
<!--#include file="../includes/abrebanco2.asp"-->
<!--#include file="travar.asp"-->
<% Call abreimo %>
<%
var_id = Request.QueryString("id")
var_categoria = Request.QueryString("categoria")
var_categoria2 = Request.form("f_categoria")
var_tipo = Request.form("f_tipo")
var_local = Request.form("f_local")
var_endereco = Request.form("f_endereco")
var_numero = Request.form("f_numero")
var_area = Request.form("f_area")
var_dormitorio = Request.form("f_dormitorios")
var_suite = Request.form("f_suites")
var_preco = Request.form("f_preco")
var_condicoes = Request.form("f_condicoes")
var_descricao = Request.form("f_descricao")
var_destaque = Request.form("f_destaque")

sql = "UPDATE imoveis SET categoria = '"& var_categoria2 &"', tipo = '"& var_tipo &"',"
sql = sql & "cidade = '"& var_local &"',"
sql = sql & "endereco = '"& var_endereco &"', numero = '"& var_numero &"',"
sql = sql & "dormitorio = '"& var_dormitorio &"', suite = '"& var_suite &"',"
sql = sql & "preço = '"& var_preco &"', cond_pagamento = '"& var_condicoes &"',"
sql = sql & "descricao = '"& var_descricao &"',"
sql = sql & "desc_destaque = '"& var_destaque &"' WHERE id LIKE '"& var_id &"' AND categoria = '"& var_categoria &"'"
Set atualiza = banco.execute(sql)
%>
<title><%=titulo%></title>
<body bgcolor="<%=fundo%>" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<link href="<%=local%>includes/styles/link.css" rel="stylesheet" type="text/css">
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <!--#include file="../includes/barraadm.asp"-->
    </td>
  </tr>
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="159" height="249" valign="top">
            <!--#include file="../includes/menuesqadm.asp"-->
          </td>
          <td width="60%" valign="top"><table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                    <tr> 
                      <td><div align="center"><%=fonte02%>O im&oacute;vel selecionado 
                          foi alterado corretamente.</div></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td><div align="center"><%=fonte01%><a href="imoveis.asp">Voltar</a></div></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
          <td width="154" valign="top">
            <!--#include file="../includes/menudiradm.asp"-->
          </td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td><!--#include file="../includes/rodapeadm.asp"--></td>
  </tr>
</table>
</body>
<% call fechaimo %>

já GASTEI HORAS COM ESSE PROBLEMA , E A BAGAÇA não FUNCIONA DE JEITO NENHUM!!!!

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Qual é o nome da "pagina q insere os dados do formulario no BD" ??

Creio que o "problema" seja porque você está usando o enctype="multipart/form-data" no form do altera2.asp. O problema é neste UPDATE??

sql = "UPDATE imoveis SET categoria = '"& var_categoria2 &"', tipo = '"& var_tipo &"',"
sql = sql & "cidade = '"& var_local &"',"
sql = sql & "endereco = '"& var_endereco &"', numero = '"& var_numero &"',"
sql = sql & "dormitorio = '"& var_dormitorio &"', suite = '"& var_suite &"',"
sql = sql & "preço = '"& var_preco &"', cond_pagamento = '"& var_condicoes &"',"
sql = sql & "descricao = '"& var_descricao &"',"
sql = sql & "desc_destaque = '"& var_destaque &"' WHERE id LIKE '"& var_id &"' AND categoria = '"& var_categoria &"'"
Set atualiza = banco.execute(sql)
tenta debugar, tipo
response.write sql
response.end
Set atualiza = banco.execute(sql)

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,5k
×
×
  • Criar Novo...