Alex007152 Posted July 18, 2007 Share Posted July 18, 2007 Hi, I've desperately searched on this one for hours and it has frustrated me to no end. I've contacted my webhost, posted it on the firefox forums but they all point at the script self. Here's the code: $TopicID = (get_magic_quotes_gpc()) ? $_GET['Topic'] : addslashes($_GET['Topic']); mysql_query("UPDATE topics SET topic_views=topic_views+1 WHERE topic_id=$TopicID"); It's so simple and short and can yet cause so such a headache. The point of it is to increment the amount of views of a topic with ONE. MSIE7 seemed to increment correctly, FireFox not. I'm going to test more browsers but really, there is absolutely no logical reason on why the field topic_views gets incremented with random numbers ranging from one to four with firefox. I've tested this code on an empty seperate page and it worked fine, but the origional code is just as isolated from the rest of the code as on the seperate page. Any ideas? I'd eat my shoes if this is really due to my own code. Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 18, 2007 Share Posted July 18, 2007 it can be due to that firefox opens the page with more than one stream at one time. Give me a link and i will try it with opera Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 18, 2007 Share Posted July 18, 2007 Doubt this will fix your current problem (Could be wrong) but when you're using "WHERE this=$that", it's good practice to put the value in single quotes like this... <?php mysql_query("UPDATE `topics` SET topic_views=topic_views+1 WHERE topic_id='$TopicID'"); ?> And also putting the backticks around the table names isn't going to hurt overall. Would be amusing if that solves it for you. Quote Link to comment Share on other sites More sharing options...
Alex007152 Posted July 18, 2007 Author Share Posted July 18, 2007 Thank you for your reply. Heres a sample forum with a sample topic: http://www.mmorpghq.net/games/?GameID=3&Content=Topics&Forum=1 Caesar: I'll try that in a second, thanks. Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 18, 2007 Share Posted July 18, 2007 only +1 here, i think it is a firefox issue Quote Link to comment Share on other sites More sharing options...
Alex007152 Posted July 18, 2007 Author Share Posted July 18, 2007 only +1 here, i think it is a firefox issue I was thinking that aswell, but heres a responce from someoone from the firefox forums: There is no possible way that server-side code, including the block you posted, can be affected by the client. Well .. it could be possible if data is passed from server to client and back, or client to server. This is not your case, and although in IE your code works correctly, I would be checking somewhere else. Maybe the functions in your code look for the useragent, and then respond differently if the user is not IE? That would be my guess. Only the HTML code that is created by your server's PHP code, is processed by Firefox. Firefox doesnt process php itself. Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 18, 2007 Share Posted July 18, 2007 I would say he's correct. Quote Link to comment Share on other sites More sharing options...
lightningstrike Posted July 18, 2007 Share Posted July 18, 2007 Has to deal with mozilla firefox's about:config settings network.http.max-persistent-connections-per-server That value is user set on the browser. Meaning that firefox will request the page x times. I changed my value to 1 and it worked fine but before when it was 2 it increased your views by 2 each actual view. Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 18, 2007 Share Posted July 18, 2007 i thought i was right with the number of streams firefox done. Quote Link to comment Share on other sites More sharing options...
Alex007152 Posted July 18, 2007 Author Share Posted July 18, 2007 Has to deal with mozilla firefox's about:config settings network.http.max-persistent-connections-per-server That value is user set on the browser. Meaning that firefox will request the page x times. I changed my value to 1 and it worked fine but before when it was 2 it increased your views by 2 each actual view. Thanks ALLOT for pointing that out! I'm just not sure how to write a script that deals with it though, any suggestions? Quote Link to comment Share on other sites More sharing options...
Alex007152 Posted July 19, 2007 Author Share Posted July 19, 2007 Hi again, i looked up some code on my old PHPBB forum, heres the part that increments the views: // // Update the topic view counter // $sql = "UPDATE " . TOPICS_TABLE . " SET topic_views = topic_views + 1 WHERE topic_id = $topic_id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql); } It works fine, apparantly, no matter how high "network.http.max-persistent-connections-per-server" is set. According to another member from the firefox forums, it also has something to do with empty src attributes with images, making standard browsers load the page multiple times. Checked all src attributes and everything was fine however. Any idea's on how to work around it? Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 19, 2007 Share Posted July 19, 2007 Are you including the file that does the incrementing, in on another php file? Quote Link to comment Share on other sites More sharing options...
Alex007152 Posted July 19, 2007 Author Share Posted July 19, 2007 Are you including the file that does the incrementing, in on another php file? No. I tried that but it obviously had the same result. I'm going on vacation tomorow, it's too bad i didn't had the time to fix it before i have to go but i'll be looking on internet for information on the bug on internet clubs orso. I urgently need to find a way to get this to work because i'm afraid i can't continue the development of my site without having this fixed. I'd extremely highly appreciate it if someone could tell a way to work around it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.