Jump to content

shaneR

Members
  • Posts

    20
  • Joined

  • Last visited

About shaneR

  • Birthday 08/12/1975

Profile Information

  • Location
    warwickshire, England

shaneR's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. shaneR

    Automatic insert

    The below code is what im using and the insert into database code im sitting above this! <form method="post" action="<%=MM_editAction%>" name="form1"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Clickdate:</td> <td> <input type="text" name="clickdate" value="<% Response.Write(Now) %>" size="32"> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Ip:</td> <td> <input type="text" name="ip" value="<% Response.Write(Request.ServerVariables("REMOTE_ADDR")) %>" size="32"> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Pageurl:</td> <td> <input type="text" name="pageurl" value="<% Response.Write(Request.ServerVariables("SCRIPT_NAME")) %>" size="32"> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Username:</td> <td> <input type="text" name="username" value="<%= strLoggedInUserName %>" size="32"> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td> <input type="submit" value="Insert record"> </td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form>
  2. HI Everyone,I've built a site using asp and vbscript and what i need to do is have some information automatically submitted to my database upon the user arriving on the desired page.At the moment the information is automatically collected but to submit it into my database im using a form which requires the submit button to be pressed.Any ideas please?
  3. shaneR

    Automatic insert

    HI Everyone,I've built a site using asp and vbscript and what i need to do is have some information automatically submitted to my database upon the user arriving on the desired page.At the moment the information is automatically collected but to submit it into my database im using a form which requires the submit button to be pressed.Any ideas please?
  4. Thanks for your input!!I have found some similar code to that above which works really well please see below i hope this helps others out who have the same problem as me.<%strServerName = Request.ServerVariables("SERVER_NAME")If InStr(strServerName, "mydomain.com") Then strImage = "<img src=""first image"" width=""473"" height=""35"">"Else strImage = "<img src=""ialternate image"" width=""404"" height=""38"">"End If%>Place the below string where you want the image(s) to be displayed.<%= strImage %>
  5. The database im using is ACCESS 2000!!!Thankyou.
  6. Hi, could you please comment on the included code which displays questions from my database in a random order but sometimes the questions are re[eated in the same session.If you know how to stop this please show me how.Thanks all!!! <%@ Language=VBScript %><%option explicit%><!-- #INCLUDE FILE = "connect_ama.asp" --><% dim myrs set myrs = server.createobject("ADODB.recordset") myrs.open "select * from all_exams where ExamName ='" & Request.Form ("start") & "'" ,myconn '''''''''''''''''''''''''''''''''''''''''''''''''' dim q_id1, q_id2, code, totaltime, ppercent, totalq, expire, examnameq_id1 = myrs("sq_id") q_id2 = myrs("eq_id")totaltime = myrs("totalTime") totalq = myrs("totalQuestions")examname = myrs("ExamName")ppercent = myrs("ppercentage")code = myrs("code") expire = myrs("expireDate")myrs.Close session("totalquestions")=totalq''''''''''''''''''''''''''''''myrs.open "select * from q_bank where q_id between " & q_id1 & " and " & q_id2 ,myconn,3 '3=adOpenStatic,then only myrs.recordcount will work ''''''''''''''''''''''''''''''dim totalrectotalrec = myrs.RecordCount session.Contents("ExamName")=Request.Form ("start")'Response.Cookies("totaltime")= cstr(totaltime) 'if myrs.Fields("ExpireDate") < Date then'Response.Write "<h5>EXPIRED ''''''''<H5>"'end if' Response.Write "total time=" & totaltime & "<hr> total q=" & totalq & "<hr> total rec=" & totalrec &"<hr>"Dim num(),k,i,x,j,ans()redim num (totalq)redim ans (totalq)k = 1Randomize For i = 1 To totalq x = Round(Rnd * totalrec) 'give record count For j = 1 To k If num(j) = x Then i = i - 1 Exit For End If Next If j > k Then num(k) = x k = k + 1 End If Next''''''''''''''''''''''''''''''''''' for i=1 to totalq ans(i)="Not Attempted" 'Response.Write i & " | " &num(i)& " | " myrs.MoveFirst myrs.Move num(i)-1 num(i)=myrs("q_id") 'Response.Write num(i) & " |<br> " Next Session("Questions")=num Session("Answers")=ans Session("Counter")=1 Session("examover")=0 Session ("examname")= examname Session("ppercentage")= ppercent ''''''''''''''''''''''''''''''''''closing order important'''''''''myrs.closemyconn.closeset myconn=nothingset myrs=nothing''''''''''''''''''''''''''''''''''Response.Redirect "exam_paper.asp"Response.Cookies(examname & "totaltime")= cstr(totaltime) %><HTML><HEAD></HEAD><BODY><form name=examform action="exam_paper.asp" method=post> <input type=hidden name=qno value=1> <input type=hidden name=totalq value=<%=totalq%>> </form> <script language="JavaScript"> document.examform.submit() </script> </BODY></HTML> The include file::: <%@ Language=VBScript %><%Response.Cookies("totaltime")="300"%><% Dim num(), k,ans(),totalq totalq=100 redim num(totalq) redim ans(totalq) k = 1 Randomize For i = 1 To totalq x = Round(Rnd * totalq) For j = 1 To k If num(j) = x Then i = i - 1 Exit For End If Next If j > k Then num(k) = x k = k + 1 End If Next for i=1 to totalq ans(i)="Not Attempted" Response.Write num(i)& ".<br>" Next Session("Questions")=num Session("Answers")=ans Session("Counter")=1 Session("examover")=0 'Response.Cookies("totaltime")= "400" 'cstr(totaltime) %> <form name=examform action="exam1.asp" method=post> <input type=hidden name=qno value=1> <input type=submit name="xxxxxxxx" value=1> </form> <script language="JavaScript"> // document.examform.submit() </script> <P> </P></BODY></HTML>
  7. HI i wonder if anyone knows any neat code to place onto my site?Basically i have two different domain names running from the same site and i need to have a different logo display depending on the URL used to access my site.Any ideas?
  8. Thankyou after taking your comments into consideration im now able to perform the delete from both the server and database.Regards,Shane
  9. Hi everyone! my database site is now uploading files to my server and at the same time writting this file name and the users id to my database. What i need to do now is allow the user to access their own content and be able to delete this from the server and database.I have already been trying a few different methods but i just cant seem to get my head around it.Any code or advice would be appreciated, Thanks
  10. shaneR

    track uploads?

    Yes im using a form connected to an asp page. I have not included any cookies or sessions that im aware of so that sounds like the way to go? Thanks
  11. shaneR

    track uploads?

    I have created the user log in details in a database and these details are checked when they log into my page that allows them to then upload direct to my server. I now need a way of identifying the files uploaded by the different user in order to call them back into my database for users to view etc.I hope this makes a little more sense, thankyou.
  12. shaneR

    track uploads?

    My database is now working fine! thanks to all. However i have now set it up so that users can log in and upload files to my server. How can i automatically have a copy of their file names sent to my database perhaps with their user log on id also?I would appreciate some code if possible (iam currently using dreamweaver to write my pages)Thankyou...
  13. Thanks for all that have taken the tome to look at this problem. I have discovered what was the cause and as usual it is something very simple.Basically one of my field names is called PASSWORD and as this is whats known as a reserved word i have changed it and now the site works.
  14. Hi, i wonder if anybody would be as kind to take a look at the attached code. Im trying to set up a form which when submitted the required information is sent to my database.The error which is displaying is as follows:Microsoft JET Database Engine error '80040e14'Syntax error in INSERT INTO statement./Shane_R/my_music_profile/web_site_construction/www/upload.asp, line 115 Thankyou..... <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><!--#include file="../Connections/con1.asp" --><%' *** Edit Operations: declare variablesDim MM_editActionDim MM_abortEditDim MM_editQueryDim MM_editCmdDim MM_editConnectionDim MM_editTableDim MM_editRedirectUrlDim MM_editColumnDim MM_recordIdDim MM_fieldsStrDim MM_columnsStrDim MM_fieldsDim MM_columnsDim MM_typeArrayDim MM_formValDim MM_delimDim MM_altValDim MM_emptyValDim MM_iMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)End If' boolean to abort record editMM_abortEdit = false' query string to executeMM_editQuery = ""%><%' *** Insert Record: set variablesIf (CStr(Request("MM_insert")) = "form1") Then MM_editConnection = MM_con1_STRING MM_editTable = "register" MM_editRedirectUrl = "upload.asp" MM_fieldsStr = "Email|value|Prefferedmusictype|value|Password|value|Profilename|value" MM_columnsStr = "Email|',none,''|Prefferedmusictype|',none,''|Password|',none,''|Profilename|',none,''" ' create the MM_fields and MM_columns arrays MM_fields = Split(MM_fieldsStr, "|") MM_columns = Split(MM_columnsStr, "|") ' set the form values For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i))) Next ' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End IfEnd If%><%' *** Insert Record: construct a sql insert statement and execute itDim MM_tableValuesDim MM_dbValuesIf (CStr(Request("MM_insert")) <> "") Then ' create the sql insert statement MM_tableValues = "" MM_dbValues = "" For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_formVal = MM_fields(MM_i+1) MM_typeArray = Split(MM_columns(MM_i+1),",") MM_delim = MM_typeArray(0) If (MM_delim = "none") Then MM_delim = "" MM_altVal = MM_typeArray(1) If (MM_altVal = "none") Then MM_altVal = "" MM_emptyVal = MM_typeArray(2) If (MM_emptyVal = "none") Then MM_emptyVal = "" If (MM_formVal = "") Then MM_formVal = MM_emptyVal Else If (MM_altVal <> "") Then MM_formVal = MM_altVal ElseIf (MM_delim = "'") Then ' escape quotes MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'" Else MM_formVal = MM_delim + MM_formVal + MM_delim End If End If If (MM_i <> LBound(MM_fields)) Then MM_tableValues = MM_tableValues & "," MM_dbValues = MM_dbValues & "," End If MM_tableValues = MM_tableValues & MM_columns(MM_i) MM_dbValues = MM_dbValues & MM_formVal Next MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")" If (Not MM_abortEdit) Then ' execute the insert Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End IfEnd If%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><form method="post" action="<%=MM_editAction%>" name="form1"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Email:</td> <td> <input type="text" name="Email" value="" size="32"> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Prefferedmusictype:</td> <td> <input type="text" name="Prefferedmusictype" value="" size="32"> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Password:</td> <td> <input type="text" name="Password" value="" size="32"> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Profilename:</td> <td> <input type="text" name="Profilename" value="" size="32"> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td> <input type="submit" value="Insert record"> </td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"></form><p> </p></body></html>
  15. Thankyou, just tried that and i have resized all my pages to 101% and they all now align without any jumping... Regards Shane.
×
×
  • Create New...