30. oktober 2003 - 16:38Der er
4 kommentarer og 1 løsning
Gem i database!
Hejsa!
Jeg leger med noget statistik på et asp hotel som kører mysql!
Alt virker fint pånær når man skal gemmen i nedenstående fil! hvor den brokker sig i linie 34
hvilket er:
Con.Close '- her Set Con = Nothing %>
også i bunden af nedenstående kode------------
<%@LANGUAGE="VBSCRIPT"%> <!--#include file="Connections/counter.asp" --> <% Function fixQuotes( theString ) fixQuotes = Replace( theString, "'", "''" ) End Function
IP = Request.ServerVariables("REMOTE_ADDR") URL = Request.ServerVariables("URL")
If Session("Reload") <> "" & IP & "," & URL & "" Then Session("Reload") = "" & IP & "," & URL & ""
Sql = "SELECT * FROM sider WHERE URL = '" & URL & "'" Set RS = Con.Execute(Sql)
If (RS.BOF Or RS.EOF) Then Count = 1 SqlNy = "INSERT INTO sider (URL, Count) VALUES('" & fixQuotes(URL) & "','" & fixQuotes(Count) & "')" Con.Execute(SqlNy) End If
If Not (RS.BOF Or RS.EOF) Then Site = RS("URL") End If
If Site = URL Then Count = RS("Count") + 1 SqlCount = "UPDATE sider SET Count='" & Count & "' WHERE URL = '" & URL & "'" Con.Execute(SqlCount) End If End If
Du har ikke noget con.open i den viste kode. Den kunne ligge i din include fil. Hvis der ikke er nogen der, så er det nok problemet. Din kode kan nå til linie 34 (con.close) uden at have forsøt con.execute, hvis conditionen i Session("Reload") <> "" & IP & "," & URL & "" aldrig bliver sand.
Min include ser således ud connection, er der noget i ovenstående man skal ændres således koden kommer til at virker! koden har virket med access men nu skal den køre på mysql!
Den kommer dog nu med følgende fejl på en computer hvor ipen ikke har været kørt før!
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'Execute'
/tester/pagecount.asp, line 29
den nye kode er som følger....................
<%@LANGUAGE="VBSCRIPT"%> <!--#include file="Connections/counter.asp" --> <% Dim Con Dim Con_numRows
Set Con = Server.CreateObject("ADODB.Recordset") Con.ActiveConnection = MM_counter_STRING Con.Source = "SELECT * FROM sider" Con.CursorType = 0 Con.CursorLocation = 2 Con.LockType = 1 Con.Open()
Con_numRows = 0 %> <% Function fixQuotes( theString ) fixQuotes = Replace( theString, "'", "''" ) End Function
IP = Request.ServerVariables("REMOTE_ADDR") URL = Request.ServerVariables("URL")
If Session("Reload") <> "" & IP & "," & URL & "" Then Session("Reload") = "" & IP & "," & URL & ""
Sql = "SELECT * FROM sider WHERE URL = '" & URL & "'" Set RS = Con.Execute(Sql) ' **********her sker fejlen*******
If (RS.BOF Or RS.EOF) Then Count = 1 SqlNy = "INSERT INTO sider (URL, Count) VALUES('" & fixQuotes(URL) & "','" & fixQuotes(Count) & "')" Con.Execute(SqlNy) End If
If Not (RS.BOF Or RS.EOF) Then Site = RS("URL") End If
If Site = URL Then Count = RS("Count") + 1 SqlCount = "UPDATE sider SET Count='" & Count & "' WHERE URL = '" & URL & "'" Con.Execute(SqlCount) End If End If
<%@LANGUAGE="VBSCRIPT"%> <!--#include file="Connections/counter.asp" --> <% Dim Con Dim Con_numRows Dim RS
Set Con = Server.CreateObject("ADODB.Connection") Con.Open MM_counter_STRING
Con_numRows = 0 %> <% Function fixQuotes( theString ) fixQuotes = Replace( theString, "'", "''" ) End Function
IP = Request.ServerVariables("REMOTE_ADDR") URL = Request.ServerVariables("URL")
If Session("Reload") <> "" & IP & "," & URL & "" Then
Session("Reload") = "" & IP & "," & URL & ""
Sql = "SELECT * FROM sider WHERE URL = '" & URL & "'" Set RS = Con.Execute(Sql)
If (RS.BOF Or RS.EOF) Then Count = 1 SqlNy = "INSERT INTO sider (URL, Count) VALUES('" & fixQuotes(URL) & "','" & fixQuotes(Count) & "')" Con.Execute(SqlNy) else Site = RS("URL") End If
If Site = URL Then Count = RS("Count") + 1 SqlCount = "UPDATE sider SET Count='" & Count & "' WHERE URL = '" & URL & "'" Con.Execute(SqlCount) End If End If
%> <% Con.Close() Set RS = Nothing Set Con = Nothing %>
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.