Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

wolfphw

Naum consigo apagar registro

Recommended Posts

Tipo eu naum to conseguindo apagar um registro da base de dados, to usando ASP com MySql

 

Segue abaixo os codigos fontes pra vê se alguem consegue ver o erro ai.

 

excluir.asp

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="../../Connections/todimo2.asp" --><%' *** comeco da autenticacaoMM_authorizedUsers=""MM_authFailedURL="index.asp"MM_grantAccess=falseIf Session("MM_Username") <> "" Then  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then    MM_grantAccess = true  End IfEnd IfIf Not MM_grantAccess Then  MM_qsChar = "?"  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"  MM_referrer = Request.ServerVariables("URL")  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)  Response.Redirect(MM_authFailedURL)End If' *** final da autenticacao%><%id_noticias = request.querystring("cod")sql = "select * from noticias where id_noticias = "& id_noticias &""Set Rs = conexao.execute(sql)titulo = rs.fields("titulo")texto = rs.fields("texto")fonte = rs.fields("fonte")data = rs.fields("data")%><html><head><title>Todimo Notícias ADM</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body leftmargin="0" topmargin="0"><p><br>     <img src="imagens/logo_adm.jpg" width="237" height="52"> </p><table width="770" border="0" cellspacing="0" cellpadding="0">  <tr>    <td> </td>    <td bgcolor="#FFCC00"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong> :         : E X C L U I R  : :   N O T Í C I A S : : </strong></font></div></td>  </tr>  <tr>     <td width="10"> </td>    <td width="760"><form name="form1" method="post" action="excluir2.asp">        <table width="760" border="0" cellspacing="2" cellpadding="2">          <tr>             <td width="48"><div align="right"><font size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Título: </font></strong></font></div></td>            <td width="698"><input name="titulo" type="text" id="titulo" value="<%=titulo%>" size="50"></td>          </tr>          <tr>             <td><div align="right"><font size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Fonte: </font></strong></font></div></td>            <td><input name="fonte" type="text" id="fonte" value="<%=fonte%>" size="50"></td>          </tr>          <tr>             <td><div align="right"><font size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Data: </font></strong></font></div></td>            <td><input name="data" type="text" id="data" value="<%=data%>" size="10">               <strong><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif">Ex:               dd/mm/aaaa</font></strong></td>          </tr>          <tr>             <td valign="top"><div align="right"><font size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Texto: </font></strong></font></div></td>            <td><textarea name="texto" cols="60" rows="9" id="texto"><%=texto%></textarea></td>          </tr>          <tr>             <td> </td>            <td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><font color="#FF0000"><br></font></strong>               Muda de linha<br>              <br>              <strong><font color="#FF0000"><strong></font></strong> Negrito<br>              Ex: Este é o <strong><font color="#FF0000"><strong></font></strong>adm               do<strong><font color="#FF0000"></strong></font></strong>               site - Este é o <strong>adm do</strong> site<br>              <strong><font color="#FF0000"><br>              <em></font></strong> Itálico <br>              Ex: Este é o <strong><font color="#FF0000"><em></font></strong>adm               do<strong><font color="#FF0000"></em></font></strong> site               - Este é o <em>adm do</em> site<br>              <br>              Pode juntar o itálico e negrito numa palavra<br>              Ex: Este é o <strong><font color="#FF0000"><strong><em></font></strong>adm               do<strong><font color="#FF0000"></em></strong></font></strong>               site - Este é o <em><strong>adm do</strong></em> site</font></td>          </tr>          <tr>             <td> </td>            <td> <input name="cod" type="hidden" id="cod" value="<%=id_noticias%>"></td>          </tr>          <tr>             <td> </td>            <td> <input type="submit" name="Submit" value="Excluir"> </td>          </tr>        </table>      </form></td>  </tr></table><p> </p></body></html><%Rs.Close()conexao.Close()Set rs = NothingSet conexao = Nothing%>

excluir2.asp

 

ASP [/tr][tr]

<%@LANGUAGE="VBSCRIPT"%>

<!--#include file="../../Connections/todimo2.asp" -->

<%

' *** comeco da autenticacao

MM_authorizedUsers=""

MM_authFailedURL="index.asp"

MM_grantAccess=false

If Session("MM_Username") <> "" Then

If (true Or CStr(Session("MM_UserAuthorization"))="") Or _

(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then

MM_grantAccess = true

End If

End If

If Not MM_grantAccess Then

MM_qsChar = "?"

If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"

MM_referrer = Request.ServerVariables("URL")

if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()

MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)

Response.Redirect(MM_authFailedURL)

End If

' *** final da autenticacao

%>

<%

cod = request.form("cod")

 

sql = "delete * from noticias where id_noticias = '"& cod &"' "

Response.Write sql

response.end

Set Rs = conexao.execute(sql)

response.redirect "lista.asp"

 

Rs.Close()

conexao.Close()

Set rs = Nothing

Set conexao = Nothing

%>

[/tr]

 

Ele escreve isso na tela quando executa essa pagina excluir2.asp

delete * from noticias where id_noticias = '8'

Compartilhar este post


Link para o post
Compartilhar em outros sites

o campo id noticias é textou ou numero???se for numero tira aspa

Compartilhar este post


Link para o post
Compartilhar em outros sites

Na base de dados ele eh numero

 

Jah tentei fazer de varias formas e naum deu certo.

Olha as combinaçoes que eu jah tentei

 

sql = "delete * from noticias where id_noticias = '"& cod &"' "

escreve = delete * from noticias where id_noticias = '8'

 

sql = "delete * from noticias where id_noticias = "& cod &" "

escreve = delete * from noticias where id_noticias = 8

 

sql = "delete * from noticias where id_noticias = '& cod &' "

escreve = delete * from noticias where id_noticias = '& cod &'

 

sql = "delete * from noticias where id_noticias = '" cod "' "

escreve = Erro de compilação do Microsoft VBScript (0x800A0401)

Fim da instrução esperado

/todimo/novo/noticias/excluir2.asp, line 27, column 53

sql = "delete * from noticias where id_noticias = '" cod "' "

 

sql = "delete * from noticias where id_noticias = " cod " "

escreve = Tipo de erro:

Erro de compilação do Microsoft VBScript (0x800A0401)

Fim da instrução esperado

/todimo/novo/noticias/excluir2.asp, line 27, column 52

sql = "delete * from noticias where id_noticias = " cod " "

 

sql = "delete * from noticias where id_noticias = ' cod ' "

escreve = delete * from noticias where id_noticias = ' cod '

 

sql = "delete * from noticias where id_noticias = cod "

escreve = delete * from noticias where id_noticias = cod

Compartilhar este post


Link para o post
Compartilhar em outros sites

tente assimsql = "delete * from noticias where id_noticias = "& codverifica se o id 8 existe mesmo

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ele existe sim, que eu to pegando de uma listagem que manda a informação para o excluir.aspAgora escreveu = delete * from noticias where id_noticias = 9Tipo no bando essa id_noticias eh um campo INT primario autonumerico, faz alguma diferença???( reclamação eu gosto do Sql Server nunca tive problema com ele :( )

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tipo jah tentei fazer ele apagar usando outra coluna da basa, a de titulo.Mandei os valores do titulo e fiz o seguinte sql = "delete * from noticias where titulo = "& titulo &" "E naum apaga tbTentei tb sql = "delete * from noticias where titulo = '"& titulo &"' "nada tb

Compartilhar este post


Link para o post
Compartilhar em outros sites

Valeu veio, mas pq o MySql naum tem o * pra deletar??????

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.