PHP includes_once.. multiple times?
Posted: Sat Feb 27, 2010 11:14 am
Hello, and thank you for allowing me to post on this forum. I was wondering if anyone else has run into the problem I have been dealing with for two days now. I was making a very simple counter.php file. The object of it was to load a .dat file with a line-separated count for each page that is visited like so:
index(10)
content(30)
news(23)
I thought I had made it right until I realized that it was incrementing by 3 everytime I went to my page. I rewrote the script 3 different ways, tinkering for hours with each one thinking it was programming error I could not see. I made it write fileX where X was the page count and saw that it was definitely incrementing each one, just that it was running the same php file 3 times for each refresh. After a while I assumed php was including the file multiple times, even though I did not say it, so I set it to include_once. Finally I found a script online to test to see if it was my server, but the php script I downloaded and ran worked fine. I then started hacking my HTML code up, deleting here and there, until I found out that certain DIV elements that I deleted decreased the number of increments.. from 3 to 1.. I kept hacking away until finally I found out which div elements.. or rather which div CLASSes were causing the rror and I found this in two of my classes (hence, running the script 3 times):
background-image:url('');
Is this a known bug, and does this cause calls to the server for the same file each time? When I put a random letter in between the single quotes it stopped bugging and incremented by 1, but leaving it blank caused this error for some reason. Does anyone know why this is? I just wasted 4 hours of my life and I would like to at least gain a little kernel of knowledge from all that wasted time
index(10)
content(30)
news(23)
I thought I had made it right until I realized that it was incrementing by 3 everytime I went to my page. I rewrote the script 3 different ways, tinkering for hours with each one thinking it was programming error I could not see. I made it write fileX where X was the page count and saw that it was definitely incrementing each one, just that it was running the same php file 3 times for each refresh. After a while I assumed php was including the file multiple times, even though I did not say it, so I set it to include_once. Finally I found a script online to test to see if it was my server, but the php script I downloaded and ran worked fine. I then started hacking my HTML code up, deleting here and there, until I found out that certain DIV elements that I deleted decreased the number of increments.. from 3 to 1.. I kept hacking away until finally I found out which div elements.. or rather which div CLASSes were causing the rror and I found this in two of my classes (hence, running the script 3 times):
background-image:url('');
Is this a known bug, and does this cause calls to the server for the same file each time? When I put a random letter in between the single quotes it stopped bugging and incremented by 1, but leaving it blank caused this error for some reason. Does anyone know why this is? I just wasted 4 hours of my life and I would like to at least gain a little kernel of knowledge from all that wasted time