Jump to content

Saving to file and google ads


ze1d
 Share

Recommended Posts

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...