ze1d Posted September 27, 2007 Share Posted September 27, 2007 Hi all,I have a db search engine, When someone searches for something it will take him to the results page, There i'm calling SaveSearch sub which saves the word he was searching for in a text file.My problem that when I added "Google Adsense" code to that page .. It keeps doing something like "Refresh" and write the search keyword multiple times on my text file (sometimes it work fine).This is my sub: Sub SaveSearch(ByVal search) IF cpage = 1 Then Dim FS, F SET FS = Server.CreateObject("Scripting.FileSystemObject") SET F = FS.OpenTextFile(Server.MapPath("log.TXT"), 8) F.WriteLine("<p style=""font-family : Verdana;font-size : 11px;margin : 0px;"">" & Now() & " - " & Server.HTMLEncode(search) & "</p>") F.Close SET F = Nothing SET FS = Nothing End IFEnd Sub Is there anyway to fix this,Thanks very much,ze1d Link to comment Share on other sites More sharing options...
justsomeguy Posted September 27, 2007 Share Posted September 27, 2007 Either figure out what is making it write more then once and stop that from happening, or put a flag in the function to make sure it only gets written once. You already have something like that in the function, if you set the cpage variable to 0 inside the function then it won't save the same thing twice. You can set up another flag like that to make sure that the function only does the work once, even though it might get executed several times. Link to comment Share on other sites More sharing options...
ze1d Posted September 28, 2007 Author Share Posted September 28, 2007 I can't set cpage = 0 .. it wont save anything since cpage mean "Current page" and it wont be 0 in anyway.. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 30, 2007 Share Posted September 30, 2007 I was just using cpage as an example because of how it's used in the function, the function only does anything if cpage is equal to one because everything is in an if statement. You can add another if statement to only run if another variable is set to true or false and set that variable in the function so that it won't run twice. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.