Cannot update

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • revolnip

    Cannot update


    As attached is the code :

    <% Option Explicit

    dim lngTimer
    lngTimer = Timer
    %>
    <!--#include file="Connect.a sp" -->
    <!--#include file="Settings. asp" -->
    <!--#include file="Common.as p" -->

    <% Dim profile, rsUsers, pdon, apos, elen, postContent, postSubject
    topic, avatar, abortUpdate, img, i, rsForums
    if not intUID = 0 then Conn.Execute("U PDATE [Users] SE
    [LastActivePlace] = ""profile.asp?p rofile=" & Request("profil e") & """
    [LastLoggedIn]= now(), [IP] = '" & GetIP & "' WHERE [uID]=" & intUID)

    if intUID <> 0 then 'if someone has requested a profile
    Set rsUsers = Conn.Execute("S ELECT * From [Users] WHERE [uID] = "
    intUID)
    Else
    Set Conn = nothing
    rsUsers.close

    response.redire ct "default.as p"
    end if

    If Request("update ") = "true" then

    function FormatString(x)
    x = replace(x, "'", "''")
    'x = replace(x, """", """""")
    x = Replace(x, "<", "&lt;")
    x = Replace(x, ">", "&gt;")
    x = Replace(x, vbCrLf, "<br>")
    FormatString = x
    end function

    'get data, validate it
    dim strSQL, dbpass, email, RealName, uage, Gender, uContact, uModel
    uPlate, location, website, aol, icq, msn, yahoo, interests, sig
    HideEmail
    email = Replace(Request ("email"), "'", "''")
    if len(email) < 6 then elen = true
    if instr(email, "@") = 0 then elen = true
    'response.write instr("asd", "@") & " : " & instr("asd@asd" , "@")
    realname = FormatString(Re quest("realname "))
    uage = FormatString(Re quest("uage"))
    gender = FormatString(Re quest("Gender") )
    uContact = FormatString(Re quest("uContact "))
    uModel = FormatString(Re quest("uModel") )
    uPlate = FormatString(Re quest("uPlate") )
    location = FormatString(Re quest("location "))
    website = FormatString(Re quest("website" ))
    If len(website) > 1 then
    If lCase(Left(webs ite, 4)) <> "http" then website = "http://"
    website
    End If
    aol = FormatString(Re quest("aol"))
    icq = FormatString(Re quest("icq"))
    msn = FormatString(Re quest("msn"))
    yahoo = FormatString(Re quest("yahoo"))
    interests = FormatString(Re quest("interest s"))
    sig = Request("sig")
    postContent = sig
    Set rsForums = Conn.Execute("S ELECT General.*, PER_TEMPLATE.* Fro
    [General] INNER JOIN PER_TEMPLATE ON General.PER" & intGroup & "
    PER_TEMPLATE.TE MPLATE_ID") 'should hopefully stop errors occuring i
    formatpost.asp
    dim POST_HTML, POST_BB, POST_SMILIE, POST_IMG
    POST_HTML = false
    POST_BB = true
    POST_SMILIE = true
    POST_IMG = true
    %>
    <!--#include file="FormatPos t.asp" -->
    <%
    sig = postContent

    avatar = FormatString(Re quest("avatar") )
    HideEmail = Request("hideem ail")
    if HideEmail = "true" then HideEmail = true else HideEmail = false

    'update record
    'if not abortUpdate = true then 'if all good then
    strSQL = "UPDATE [Users] SET "
    if not elen = true then
    strSQL = strSQL & "[uEmail] = '" & email & "', "
    end if
    strSQL = strSQL & "[RealName] = '" & realname & "', "
    strSQL = strSQL & "[uAge] = '" & uage & "', "
    strSQL = strSQL & "[Gender] = '" & gender & "', "
    strSQL = strSQL & "[uContact] = '" & uContact & "', "
    strSQL = strSQL & "[uModel] = '" & uModel & "', "
    strSQL = strSQL & "[uPlate] = '" & uPlate & "', "
    strSQL = strSQL & "[location] = '" & location & "', "
    strSQL = strSQL & "[website] = '" & website & "', "
    strSQL = strSQL & "[icq] = '" & icq & "', "
    strSQL = strSQL & "[msn] = '" & msn & "', "
    strSQL = strSQL & "[aol] = '" & aol & "', "
    strSQL = strSQL & "[yahoo] = '" & yahoo & "', "
    strSQL = strSQL & "[interests] = '" & interests & "', "
    strSQL = strSQL & "[sig] = '" & sig & "', "

    if Application("AV _ENABLED") = true then
    strSQL = strSQL & "[Avatar] = '" & avatar & "', "
    end if
    strSQL = strSQL & "[HideEmail] = " & HideEmail & ", "
    strSQL = strSQL & " WHERE uID = " & intUID
    'response.write strSQL
    Conn.Execute (strSQL)
    end if
    'end if
    rsUsers.Requery

    intOffSet = rsUsers("Offset ")
    %>
    <html>
    <head>
    <title><%=Appli cation("FORUM_T ITLE")%> Profile</title>
    <meta http-equiv="Content-Type" content="text/html
    charset=iso-8859-1">
    <link rel="stylesheet " href="o0m.css" type="text/css">
    </head>

    <body text="#000000">
    <!--#include file="header.as p" -->
    <br>
    <table width="95%" border="0" cellspacing="1" cellpadding="0"
    align="center" class="tdBorder ">
    <tr>
    <td class="tdLighte st"><table width="100%" border="0"
    cellspacing="0" cellpadding="0" >
    <tr>
    <td width="9"><img src="images/topbar_Left.gif " width="9"
    height="25"></td>
    <td background="ima ges/topbar_grad.gif "> <div
    align="center"> <img src="images/topbar_Profile. gif"></div></td>
    <td width="6" align="right">< img
    src="images/topbar_right.gi f" width="6" height="25"></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="20" class="tdLighte st"> <p>&nbsp;<a
    href="default.a sp">o0mBBS</a>
    &gt; <a href="cpanel.as p">Control Panel</a> &gt; Update
    Profile</p></td>
    </tr>
    <tr>
    <td colspan="3" class="tdLighte st">
    <table width="100%" border="0" cellspacing="0" cellpadding="10 ">
    <tr>
    <td><table width="100%" border="0" cellspacing="1"
    cellpadding="5" class="tdBorder ">
    <tr class="tdLighte st">
    <td><p align="center"> <a
    href="cpanel.as p">Overview</a></p></td>
    <td><p align="center"> <strong>Updat e Profile</strong>
    </p></td>
    <td><p align="center"> <a href="editpass. asp">Edit
    Password</a></p></td>
    <td><p align="center"> <a href="pm.asp">P rivate
    Messages</a></p></td>
    <td><p align="center"> <a href="theme.asp ">Theme
    Manager</a></p></td>
    <td><p align="center"> <a href="buddyList .asp">Buddy
    List</a></p></td>
    <td><p align="center"> <a
    href="faq.asp"> Help</a></p></td>
    </tr>
    </table>
    <br>
    <form name="form1" method="post"
    action="UpdateP rofile.asp?upda te=true">
    <table width="100%" border="0" cellpadding="5"
    cellspacing="1" class="tdBorder ">
    <tr class="tdHeader ">
    <td height="15" colspan="2"> <p align="center"
    class="tdHeader Font"><strong>E dit
    My Profile</strong></p></td>
    </tr>
    <tr class="tdLighte st">
    <td width="150" height="15" class="tdLight" ><p
    align="right">I d
    : </p></td>
    <td><p><%=rsUse rs.Fields("uID" )%></p></td>
    </tr>
    <tr class="tdLighte st">
    <td height="30" class="tdLight" > <p
    align="right">N ame :</p></td>
    <td> <p><%=rsUsers.F ields("uName")% ></p></td>
    </tr>
    <tr class="tdLighte st">
    <td height="30" class="tdLight" > <p
    align="right">E mail : </p></td>
    <td><p>
    <input name="email" type="text" class="button"
    id="email" value="<%=rsUse rs.Fields("uEma il")%>" size="50">
    <% if elen = true then %>
    *Need proper email address
    <% end if %>
    </p></td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p align="right">R eal
    Name :
    </p></td>
    <td><input name="realname" type="text" class="button"
    value="<%=rsUse rs("RealName")% >" size="50"></td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p align="right">A ge
    :
    </p></td>
    <td><input name="uage" type="text" class="button"
    value="<%=rsUse rs("uage")%>" size="10"></td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p
    align="right">G ender : </p></td>
    <td><select name="gender" class="button" ID=Select1>
    <option value="0"<%If rsUsers("gender ") = "0" then %>
    selected<% end if %>>Undisclosed </option>
    <option value="1"<%If rsUsers("gender ") = "1" then %>
    selected<% end if %>>Male</option>
    <option value="2"<%If rsUsers("gender ") = "2" then %>
    selected<% end if %>>Female</option>
    </select></td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" > <p
    align="right">C ontact No :
    </p></td>
    <td> <input type="text" name="uContact"
    value="<%=rsUse rs("uContact")% >" class="button">
    </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" > <p align="right">C ar
    Model :
    </p></td>
    <td> <input type="text" name="uModel"
    value="<%=rsUse rs("uModel")%> " class="button">
    </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" > <p align="right">C ar
    Plate No. :
    </p></td>
    <td> <input type="text" name="uPlate"
    value="<%=rsUse rs("uPlate")%> " class="button">
    </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" > <p
    align="right">L ocation :
    </p></td>
    <td> <input type="text" name="location"
    value="<%=rsUse rs("Location")% >" class="button">
    </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p
    align="right">W ebsite : </p></td>
    <td><input name="website" type="text"
    value="<%=rsUse rs("WebSite")%> " class="button"> </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p align="right">A OL
    : </p></td>
    <td><input name="aol" type="text"
    value="<%=rsUse rs("AOL")%>" class="button"> </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p align="right">I CQ
    : </p></td>
    <td><input name="icq" type="text"
    value="<%=rsUse rs("ICQ")%>" class="button"> </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p align="right">M SN
    : </p></td>
    <td><input name="msn" type="text"
    value="<%=rsUse rs("MSN")%>" class="button"> </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p
    align="right">Y ahoo : </p></td>
    <td><input name="yahoo" type="text"
    value="<%=rsUse rs("YAHOO")%>" class="button"> </td>
    </tr>
    <tr class="tdLighte st">
    <td height="15" class="tdLight" ><p
    align="right">I nterests :
    </p></td>
    <td><textarea name="interests "
    class="button"> <%=rsUsers.Fiel ds("Interests") %></textarea>
    </td>
    </tr>
    <tr class="tdLighte st">
    <td height="30" class="tdLight" > <p
    align="right">R egistered
    On : </p></td>
    <td> <p><%=rsUsers.F ields("Register edOn")%></p></td>
    </tr>
    <tr class="tdLighte st">
    <td height="30" class="tdLight" > <p
    align="right">P osts : </p></td>
    <td> <p><%=rsUsers.F ields("Posts")% ></p></td>
    </tr>
    <tr class="tdLighte st">
    <td height="30" class="tdLight" > <p align="right">S ig
    : </p></td>
    <td> <textarea name="sig" class="button"> <%If
    rsUsers("Sig") <> "" then response.write
    ConvertBack(rsU sers.Fields("Si g"))%></textarea>
    </td>
    </tr>
    <tr class="tdLighte st">
    <td class="tdLight" > <p align="right">H ide my email:
    </p></td>
    <td> <input name="hideemail " type="checkbox"
    value="true" <% if rsUsers("HideEm ail") = true then %> checked<% end if
    %>></td>
    </tr>
    <% if Application("AV _ENABLED") = true then %>
    <tr class="tdLighte st">
    <td class="tdLight" > <p
    align="right">A vatar</p></td>
    <td> <table width="100%" border="0" cellspacing="0"
    cellpadding="0" >
    <tr>
    <td valign="top"> <p>
    <input name="avatar" type="text"
    class="button" id="avatar" value="<%=rsUse rs("Avatar")%>" >
    </p>
    </td>
    <td align="center"> <p><strong>Curr ent
    IMG</strong></p>
    <p>
    <% if rsUsers("Avatar ") <> "" then %>
    <img src="<%=rsUsers ("Avatar")%> "
    alt="avatar">
    <% else %>
    None
    <% end if %>
    </p></td>
    </tr>
    </table></td>
    </tr><% end if %>
    <tr class="tdLighte st">
    <td colspan="2"> <div align="center">
    <input name="enBB" type="hidden" id="enBB" value="true">
    <input name="profile" type="hidden" id="profile"
    value="<%=profi le%>">
    <input type="submit" name="Submit" value="Update"
    class="button">
    </div></td>
    </tr>
    </table>
    </form>

    </td>
    </tr>
    </table>

    </td>
    </tr>
    </table>
    <br>
    <br>
    <!--#include file="../common/footer.asp" -->
    </body>
    </html>
    <% rsUsers.close
    Conn.close
    %>



    --
    revolnip
    ------------------------------------------------------------------------
    Posted via http://www.codecomments.com
    ------------------------------------------------------------------------

  • Bob Barrows [MVP]

    #2
    Re: Cannot update

    1. tell us what database type and version you are using
    2. You are having a problem with a query - don't make us wade through a
    bunch of irrelevant html, etc to find the statement that's causing the
    problem. Extract the section of code that contains the line of code that
    raises the error and clearly label the line as the problem.
    3. Tell us the exact error message.
    4. You are using dynamic sql (which is not recommended - use Google to see
    why). You cannot debug sql statements without knowing what is being sent to
    the database. The only way to do that is to assign the statement to a
    variable and response.write it:
    strSQL = "Update ... "
    response.write strSQL
    Response.End

    Conn.Execute strSQL,,1

    Just as a guess, based on your subject, try these articles:
    http://www.aspfaq.com/show.asp?id=2062 - updatable cursor
    http://www.aspfaq.com/show.asp?id=2009 - 80004005 errors

    revolnip wrote:[color=blue]
    > As attached is the code :[/color]
    <snip>

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Comment

    Working...