Jump to content

foxhound187

Members
  • Content Count

    19
  • Joined

  • Last visited

Community Reputation

2 Neutral

About foxhound187

  • Rank
    Newbie
  1. foxhound187

    ASP Issues

    ok, sanitizing the data can wait. I seem to have got the script working so that it reads and inserts the data from the .csv file into the database however I would like to split the data, so when it inserts the data into the database rather than dumping it all in the one column it splits it into seperate columns per comma. I assume its some kind of array, but this is way over my head. Thanks
  2. foxhound187

    ASP Issues

    ok then that is what it is, the data will have single quotes in it. The log contains all the various user input searches. So how do I sanitize the data ? never heard of that before
  3. foxhound187

    ASP Issues

    I'm still getting that error, I have checked the formatting of the query many times and read the tutorial. sql = "INSERT INTO events (INDATE,FNAME,LNAME,EMP,TITLE,ADD,CITY,STATE,PCODE,EMAIL,PHN,OPTN,DIET) VALUES('"&date&"','"&Request.QueryString("givenName")&"','"&Request.QueryString("surname")&"','"&Request.QueryString("Company")&"','"&Request.QueryString("JobTitle")&"','"&Request.QueryString("Address")&"','"&Request.QueryString("City")&"','"&Request.QueryString("TState")&"','"&Request.QueryString("PostCode")&"','"&Request.QueryString("Email")&"','"&Request.QueryString("PhoneNum")&"','"&Request.QueryString("confop")&"','"&Request.QueryString("Diet")&"')" response.write SQL is displaying the insert correctly, so I don't get it ?
  4. foxhound187

    ASP Issues

    yeah I fixed it about 5 minutes after posting, then home time. the problem I'm having now is "Number of query values and destination fields are not the same." Obviously because my Select statement has 4 fields and only 1 Value. I need to split the data that's being read by each line into 4 columns so eachcan be put in each column of the database, I assume an array would be needed for this but don't know where to start ? and I've searched far andwide for this on the net, but no information on how to do it in classic ASP.
  5. foxhound187

    ASP Issues

    Ok changed the code once again, got past that error now have a new one. Microsoft JET Database Engine error '80040e14'Syntax error in INSERT INTO statement. **********************************************<%Dim connDim path path="searchlog.mdb" set conn = Server.CreateObject("ADODB.Connection") ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath(""&path&"") conn.open ConnStr Function ReadTextFile(strFilePath) Dim objFSO, objFile, strAllFile Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(strFilePath) strAllFile = "" If Not(objFile.AtEndOfStream) Then strAllFile = objFile.ReadAll End If objFile.Close Set objFile = Nothing Set objFSO = Nothing strAllFile = Replace(strAllFile, Chr(13)&Chr(10), Chr(13)) strAllFile = Replace(strAllFile, Chr(10)&Chr(13), Chr(13)) ReadTextFile = Split(strAllFile, Chr(13))End Function'usageConst FILE_NAME="searchlog.txt"Dim arrLines, x, curLineResponse.Write("reading file: " & FILE_NAME & "...<br />")arrLines = ReadTextFile(Server.MapPath(FILE_NAME))Response.Write("amount of lines: " & (UBound(arrLines)+1) & "<br />")Response.Write("file contents:<hr />")For x=0 To UBound(arrLines) curLine = arrLines(x) sql = "INSERT INTO lgsdatalog 'data,date,time,ampm' VALUES ("&Server.HTMLEncode(curLine)&")" conn.execute sql 'Response.Write("Line #" & (x+1) & " " & Server.HTMLEncode(curLine) & "<br />")'NextResponse.Write("<hr />") Response.Write "<br><br><br><br><br><br><br><br><br><br><br><br>" Response.Write "<strong><font size='16'><font face='verdana'><center>Converting log data<br />" Response.Write "<strong><font size='16'><font face='verdana'><center>into database<br />" Response.Write "<br><strong><font size='16'><font face='verdana'><center>Complete!<br />" Response.AddHeader "Refresh", "5;URL=http://" Response.Redirect("displaylog.asp") If conn.execute = False Then _ Response.Write "<br><br><br><br><br><br><br><br><br><br><br><br>" Response.Write "<strong><font size='16'><font face='verdana'><center>Failed!, did not convert into database<br />"%>
  6. Hi there I've made a couple of scripts that are working perfectly in Win7, however problems arise in WinXP.Here is the first script. ** Connect script ** Const TIMEOUT = 3On Error Resume NextSet objShell = CreateObject("WScript.Shell")Set objNetwork = CreateObject("WScript.Network")Set objFSO = CreateObject("Scripting.FileSystemObject")Set CheckDrive = objNetwork.EnumNetworkDrives()'declare variables'strDesktop = objShell.SpecialFolders("Desktop")strPath = "\\SERVER\D"strPath2 = "\\SERVER\E"strDriveLetter = "Z:"strDriveLetter2 = "X:"strProfile = TruestrUser = "*****"strPassword = "*****"AlreadyConnected = False'check if drives are connected'For intDrive = 0 To CheckDrive.Count - 1 Step 2If CheckDrive.Item(intDrive) = strDriveLetter _Then AlreadyConnected = TrueobjShell.Popup "Server Drives are Already Connected", TIMEOUTWscript.quitNext'check if drives are connected, if not connect'objShell.Popup "Connecting Server Drives" , TIMEOUTobjNetwork.MapNetworkDrive strDriveLetter , strPath , strProfile, strUser , strPasswordobjNetwork.MapNetworkDrive strDriveLetter2 , strPath2 , strProfile, strUser , strPassword'if no errors'If Err = 0 Then'create shortcut after connection established'IF Not objFSO.FileExists(objShortcutLnk) Then _Set objShortcutLnk = objShell.CreateShortcut(strDesktop & "\Server Drive.lnk")objShortcutLnk.TargetPath = strPathobjShortcutLnk.IconLocation = "%SystemRoot%\system32\SHELL32.dll,9"objShortcutLnk.SaveSet objShortcutLnk2 = objShell.CreateShortcut(strDesktop & "\Server Drive Images.lnk")objShortcutLnk2.TargetPath = strPath2objShortcutLnk2.IconLocation = "%SystemRoot%\system32\SHELL32.dll,9"objShortcutLnk2.SaveobjShell.Popup "Connection Success", TIMEOUTWscript.quit'if there are errors attempt reconnect'Else If Err <> 0 ThenobjShell.Popup "Connection Failed: " & Err.Description & vbCrLf & _ "Attempting Reconnection", TIMEOUT Err.ClearobjNetwork.MapNetworkDrive strDriveLetter , strPath , strProfile, strUser , strPasswordobjNetwork.MapNetworkDrive strDriveLetter2 , strPath2 , strProfile, strUser , strPasswordIF Not objFSO.FileExists(objShortcutLnk) Then _objShortcutLnk.TargetPath = strPathobjShortcutLnk.IconLocation = "%SystemRoot%\system32\SHELL32.dll,9"objShortcutLnk.SaveobjShortcutLnk2.TargetPath = strPath2objShortcutLnk2.IconLocation = "%SystemRoot%\system32\SHELL32.dll,9"objShortcutLnk2.SaveobjShell.Popup "Connection Success", TIMEOUTWscript.quit'check reconnection'If Err <> 0 Then _objShell.Popup "Reconnection Failed: " & Err.Description, TIMEOUT _Else _objShell.Popup "Connection Success", TIMEOUT End IfEnd If--------------------------------------------------------------------------------------- I have created this disconnect script in the event that there is an error with the connection script, you can run the disconnect and it clears the drives / shortcuts and then you can try connect again.I did this because sometimes when the connect script is run on startup if the server is lagging or whatever, it may not execute the script correctly and I've noticed it can sometimes map the drives without logging in theuser to the server. So when you try access the mapped drives, you can't login. As I say both these scripts work fine in Win7, and even when I remove On Error Resume Next it still does not come up with an error. Now the problem is in XP if you run the disconnect script after the user has clickedon the Shortcut that is created by the connect script, it somehow keeps the session open between the client and the server. So when you run the disconnect script, even though it works correctly and gets rid of themapped drives and shortcuts without any errors, when you try run the connect script again it says that the drives are still connected. This only seems to happen if the user has opened the shortcut. If you just run the connect script then the disconnect it works fine. What I want to know, is there a CreateObject("WScript.Network") object you can use with this in order to close the login session to the server, because if the session is closed when the user runs the disconnect scriptthat should prevent the session from remaining open, thus forcing the script to reconnect ? ** Disconnect Script ** Const TIMEOUT = 3On Error Resume NextSet objShell = CreateObject("WScript.Shell")Set objNetwork = CreateObject("WScript.Network")Set objFSO = CreateObject("Scripting.FileSystemObject")Set CheckDrive = objNetwork.EnumNetworkDrives()'declare variables'strDesktop = objShell.SpecialFolders("Desktop")strPath = "\\SERVER\D"strPath2 = "\\SERVER\E"strDriveLetter = "Z:"strDriveLetter2 = "X:"strProfile = TruestrUser = "*****"strPassword = "*****"AlreadyConnected = False'check for shortcut and delete'IF objFSO.FileExists(strDesktop & "\Server Drive.lnk") then _Set objShortcutLnk = objShell.CreateShortcut(strDesktop & "\Server Drive.lnk")Set objShortcutLnk2 = objShell.CreateShortcut(strDesktop & "\Server Drive Images.lnk")objFSO.DeleteFile(objShortcutLnk)objFSO.DeleteFile(objShortcutLnk2)'check if drives are connected and disconnect'For intDrive = 0 To CheckDrive.Count - 1 Step 2If CheckDrive.Item(intDrive) = strDriveLetter _Then AlreadyConnected = TrueobjNetwork.RemoveNetworkDrive strDriveLetter, True, TrueobjNetwork.RemoveNetworkDrive strDriveLetter2, True, TrueobjShell.Popup "Server Drives Disconnected", TIMEOUTWscript.quitNext'check if drives already disconnected'If AlreadyConnected = False thenobjShell.Popup "Server Drives Already Disconnected", TIMEOUTWscript.quit End If
  7. foxhound187

    ASP Issues

    I'm aware that's what the second error means, I changed the path to test if it was at least connecting and it was, because soon as I changed it I got that error. I will try specifying the connection when I create or open the recordset and let you know how I go. How is the query not in a correct format if I can print the query fine, wouldn't it of crashed ?
  8. foxhound187

    ASP Issues

    Alright code has been updated. ** searchcon.asp ** <% path="searchlog.mdb" set conn = Server.CreateObject("ADODB.Connection") ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath(""&path&"") conn.open ConnStr %> ** readlog.asp ** <!--#include file="searchcon.asp"--><% Dim FSODim FilepathDim ContentsDim MSAQDim TextStreamDim rs Const Filename = "searchlog.txt" ' file to readConst ForReading = 1, ForWriting = 2, ForAppending = 3Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 'Create a filesystem object Set FSO = server.createObject("Scripting.FileSystemObject")Set rs = server.CreateObject("ADODB.RecordSet") 'Map the logical path to the physical system path Filepath = Server.MapPath(Filename) if FSO.FileExists(Filepath) Then Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False, TristateUseDefault) Contents = TextStream.ReadAll Response.Write "<br><br><br><br><br><br><br><br><br><br><br><br>" Response.Write "<strong><font size='16'><font face='verdana'><center>Converting log data<br />" Response.Write "<strong><font size='16'><font face='verdana'><center>into database<br />" MSAQ = "INSERT INTO lgsdatalog (logdata) VALUES ('"&Contents&"')" Set rs = Server.CreateObject("ADODB.Recordset") response.Write("MSAQ="&MSAQ&";<br />") rs.open MSAQ <---- Line 37 Response.Write "<br><strong><font size='16'><font face='verdana'><center>Complete!<br />" Response.AddHeader "Refresh", "5;URL=http://" TextStream.Close Set TextStream = nothing Response.Redirect("displaylog.asp") Else Response.Write "<br><br><br><br><br><br><br><br><br><br><br><br>" Response.Write "<strong><font size='16'><font face='verdana'><center>Failed!, did not convert into database<br />" End If Set FSO = nothing%> ************* It prints out the query correctly Converting log data into database MSAQ=INSERT INTO lgsdatalog (logdata) VALUES blah blah blah, however I'm still getting the ADODB.Recordset error '800a0e7d'The connection cannot be used to perform this operation. It is either closed or invalid in this context. readlog.asp, line 37 I tried changing the path to the DB file, and it gave me a Microsoft JET Database Engine error '80004005'Could not find file 'searchlog.mdb'.searchcon.asp, line 5 So it's connecting, it just doesn't like line 37, rs.open MSAQ ???don't understand why
  9. foxhound187

    ASP Issues

    ok now I'm getting aADODB.Recordset error '800a0bb9' Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. /eventscalendar/database/readlog.asp, line 37 MSAQ = MSAQ = "INSERT INTO lgsdatalog ([logdata]) VALUES ([" & Contents & "])" Set rs = Server.CreateObject("ADODB.Recordset")line 37 ----> rs.open MSAQ
  10. seems to be working now, didn't make any changes ???oh well I won't complain.
  11. no good it seems. I've formatted the Mail body so it's a bit easier to follow. Mail.Body = "There has been a request from: " & Request.QueryString("givenName") + " " + Request.QueryString("surname") + VbCrLf _ + " Company: " + Request.QueryString("Company") + VbCrLf _ + " Job Title: " + Request.QueryString("JobTitle") + VbCrLf _ + " Address: " + Request.QueryString("Address") + VbCrLf _ + " City: " + Request.QueryString("City") + VbCrLf _ + " State: " + Request.QueryString("TState") + VbCrLf _ + " PostCode: " + Request.QueryString("PostCode") + VbCrLf _ + " Email: " + Request.QueryString("Email") + VbCrLf _ + " Phone: " + Request.QueryString("PhoneNum") + VbCrLf _ + " Booking Type: " + Request.QueryString("confop") + VbCrLf _ + " Diet: " + Request.QueryString("Diet") However it still comes out all as 1 big paragraph
  12. foxhound187

    ASP Issues

    So it should be, MSAQ = "INSERT INTO lgsdatalog ([logdata]) VALUES ([" & Contents & "]) or MSAQ = "INSERT INTO lgsdatalog ([logdata]) VALUES ([" & Contents "]) ?? Sorry I'm not very good without examples, aspergers.
  13. Hello, I'm having trouble formatting form data, it's picking up and sending everything correctlyhowever, apon arrival everything is blocked together, seem's to be coming in plain text format As you can see the body is one big chunk, if I try split it up the ASP crashes, and if I try declare a Body2 variablefor example, to help split it up, it crashes also. **example**There has been a request from: Daniel Test Company: LGS Job Title: Web developer Address: Test City: Sydney State: NSW PostCode: 2229 Email: dblah@blah.comsuper.com.au Phone: 9123456789 Booking Type: 1 night's twin share accommodation + Conference + Gala dinner for 2 people $580(inc GST) Diet: none 2nd person info: Bob Builder Company: LGS JobTitle: Boss man Address: Test City: Sydney State: NSW PostCode: 2229 Email: bobbossman@blah.com.au Phone: 9123456789 **here is my code** ' message subject Mail.Subject = "LGS Liaison Conference Registration" ' message body Mail.Body = "There has been a request from: " & Request.QueryString("givenName") + " " + Request.QueryString("surname") + "<br> Company: " + Request.QueryString("Company") + " Job Title: " + Request.QueryString("JobTitle") + " Address: " + Request.QueryString("Address") + " City: " + Request.QueryString("City") + " State: " + Request.QueryString("TState") + " PostCode: " + Request.QueryString("PostCode") + " Email: " + Request.QueryString("Email") + " Phone: " + Request.QueryString("PhoneNum") + " Booking Type: " + Request.QueryString("confop") + " Diet: " + Request.QueryString("Diet") Set fs = CreateObject("Scripting.FileSystemObject")Set f=fs.OpenTextFile(Server.MapPath("/eventscalendar/database/EMPconference12.txt"),8,true)f.WriteLine(Day(date()) & "/" & month(date()) & "/" & year(date()) & Request.QueryString("givenName") + "," + Request.QueryString("surname") + "," + Request.QueryString("Company") + "," + Request.QueryString("JobTitle") + "," + Request.QueryString("Address") + "," + Request.QueryString("City") + "," + Request.QueryString("TState") + "," + Request.QueryString("PostCode") + "," + Request.QueryString("Email") + "," + Request.QueryString("PhoneNum") + "," + Request.QueryString("confop") + "," + Request.QueryString("Diet") ) if Request.QueryString("confop") = "1 night's twin share accommodation + Conference + Gala dinner for 2 people $580(inc GST)" then f.WriteLine(Day(date()) & "/" & month(date()) & "/" & year(date()) & Request.QueryString("givenName2") + "," + Request.QueryString("surname2") + "," + Request.QueryString("Company2") + "," + Request.QueryString("JobTitle2") + "," + Request.QueryString("Address2") + "," + Request.QueryString("City2") + "," + Request.QueryString("TState2") + "," + Request.QueryString("PostCode2") + "," + Request.QueryString("Email2") + "," + Request.QueryString("PhoneNum2") ) Mail.Body = "There has been a request from: " & Request.QueryString("givenName") + " " + Request.QueryString("surname") + " Company: " + Request.QueryString("Company") + " Job Title: " + Request.QueryString("JobTitle") + " Address: " + Request.QueryString("Address") + " City: " + Request.QueryString("City") + " State: " + Request.QueryString("TState") + " PostCode: " + Request.QueryString("PostCode") + " Email: " + Request.QueryString("Email") + " Phone: " + Request.QueryString("PhoneNum") + " Booking Type: " + Request.QueryString("confop") + " Diet: " + Request.QueryString("Diet") + "2nd person info: " & Request.QueryString("givenName2") + " " + Request.QueryString("surname2") + " Company: " + Request.QueryString("Company2") + " JobTitle: " + Request.QueryString("JobTitle2") + " Address: " + Request.QueryString("Address2") + " City: " + Request.QueryString("City2") + " State: " + Request.QueryString("TState2") + " PostCode: " + Request.QueryString("PostCode2") + " Email: " + Request.QueryString("Email2") + " Phone: " + Request.QueryString("PhoneNum2") end if f.Closeset f=Nothingset fs=Nothing strErr = ""bSuccess = FalseOn Error Resume Next ' catch errorsMail.Send ' send message______________________________ Thanks
  14. foxhound187

    ASP Issues

    Yeah the MSAQ is changed because I was told the way you execute an access query is differen't to a mySQL queryso how should it be ?
  15. foxhound187

    ASP Issues

    ok that idea has been abandoned, thanks to the higher ups. Instead now will be connecting via a MS Access db, having similar issues. Here is the code searchcon.asp <-- db connection<%Private Function OpenDatabase() Set objDBConnect = Server.CreateObject("ADODB.Connection") objDBConnect.ConnectionTimeout = 6000 objDBConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("searchlog.mdb")" 'Session("ConnectionString") 'Check to see if the connection is open OK OpenDatabase = False If objDBConnect.State = 1 Then nDBConnect = 1 'Ok connected OpenDatabase = True Else nDBConnect = 0 'error connecting sError = "Unable to connect to database!" OpenDatabase = False End If End Function readlog.asp <-- read the searchlog.txt and dump into access <% Option Explicit<!--#include file="searchcon.asp"-->Dim FSODim FilepathDim ContentsDim MSAQDim TextStreamDim rsConst Filename = "searchlog.txt" ' file to readConst ForReading = 1, ForWriting = 2, ForAppending = 3Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0'Create a filesystem objectSet FSO = server.createObject("Scripting.FileSystemObject")'Map the logical path to the physical system pathFilepath = Server.MapPath(Filename)if FSO.FileExists(Filepath) Then Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False, TristateUseDefault) Contents = TextStream.ReadAll Response.Write "<br><br><br><br><br><br><br><br><br><br><br><br>" Response.Write "<strong><font size='16'><font face='verdana'><center>Converting log data<br />" Response.Write "<strong><font size='16'><font face='verdana'><center>into database<br />" MSAQ = "INSERT INTO lgsdatalog ([logdata]) VALUES ([ & Contents & ])" Set rs = Server.CreateObject("ADODB.Recordset") rs.open MSAQ Response.Write "<br><strong><font size='16'><font face='verdana'><center>Complete!<br />" Response.AddHeader "Refresh", "5;URL=http://" TextStream.Close Set TextStream = nothing Response.Redirect("displaylog.asp") Else _________________________getting the same error, ADODB.Recordset error '800a0e7d' The connection cannot be used to perform this operation. It is either closed or invalid in this context. /eventsCalendar/database/readlog.asp, line 37
×
×
  • Create New...