dave905 Posted March 28, 2008 Share Posted March 28, 2008 When using Firefox, after doing an UPDATE correctly, MySQL seems to be doing an extra/unwanted INSERT. The script works fine when run from IE but not Firefox. I've also checked this out on different computers. This is the second time some logic worked with IE but not Firefox. The first time had to do with Session Variables not getting updated in Firefox. Also my Host just switched to PHP 5. Here's the code, sorry I didn't know if there is a special way to include code. $sql = " UPDATE sessions SET"; $sql.= " session_postcount='".$postcount."'"; $sql.= ", session_remote_addr='".$remote_addr."'"; $sql.= ", session_server_id='".$server_id."'"; $sql.= " WHERE session_id='".$postsesid."';"; print $sql."<BR>"; mysql_query($sql,$dbconn) or die(mysql_error()); $sql=""; Quote Link to comment https://forums.phpfreaks.com/topic/98325-unwanted-insert-after-doing-a-mysql-update-from-a-firefox-session/ Share on other sites More sharing options...
mwasif Posted March 28, 2008 Share Posted March 28, 2008 Code is correct and is for UPDATE statement. You might have some unwanted/un-noticed ISERT somewhere which is being executed. Make sure, session is not expire in Firefox unless you close all opened Firefox windows or destroy the session explicityly. Quote Link to comment https://forums.phpfreaks.com/topic/98325-unwanted-insert-after-doing-a-mysql-update-from-a-firefox-session/#findComment-503144 Share on other sites More sharing options...
aschk Posted March 28, 2008 Share Posted March 28, 2008 Just to make it easier on people's eyes i have formatted your php+sql a little : $sql = "UPDATE sessions SET session_postcount='{$postcount}'" ,session_remote_addr='{$remote_addr}'" ,session_server_id='{$server_id}'" WHERE session_id='{$postsesid}';"; print $sql."<BR>"; mysql_query($sql,$dbconn) or die(mysql_error()); $sql=""; According to what you have provided you WILL update the sessions table with the $vars provided WHERE the session_id equals whatever is in $postsesid. There is a point somewhere else in your code that will be at fault... Quote Link to comment https://forums.phpfreaks.com/topic/98325-unwanted-insert-after-doing-a-mysql-update-from-a-firefox-session/#findComment-503197 Share on other sites More sharing options...
dave905 Posted March 28, 2008 Author Share Posted March 28, 2008 Thanks, but I've checked the code and there are no other INSERTS for this table, as well I've reset the $sql string to "" so it can't be executed anywhere else. Also this code works perfectly in IE which is why I'm so puzzled. Quote Link to comment https://forums.phpfreaks.com/topic/98325-unwanted-insert-after-doing-a-mysql-update-from-a-firefox-session/#findComment-503206 Share on other sites More sharing options...
aschk Posted March 28, 2008 Share Posted March 28, 2008 Browsers do NOT affect server side processing. Another SQL statement is being issued for other reasons. Post all your code for us to debug it. Also, what information is it putting in this "unwanted" additional row? Because an UPDATE statement CANNOT create a new row in a table Quote Link to comment https://forums.phpfreaks.com/topic/98325-unwanted-insert-after-doing-a-mysql-update-from-a-firefox-session/#findComment-503211 Share on other sites More sharing options...
dave905 Posted March 28, 2008 Author Share Posted March 28, 2008 Thanks for organizing the statement, even I can read it now. BTW what do the {}'s do? Are they just another form of quotes? Re debugging, there are over 1800 statements in the program with includes and I think that's is too much to expect anyone else to debug for me and besides: 1. It works in IE, (I know the browser should have not effect) 2. I build $sql before the update, 3. I clear $sql after the update so it can't be used anywhere else, 4. It Inserts a row into the table with all the information that is only available within the code snippet (I actually tested this by changing one of the variables to a 'hard coded' recognizable debug phrase for myself and it inserted a row with that debug phrase in it), 5. I tested it with PHP5 and got the same results 6. I actually works perfectly in IE. I've been on this for hours now, maybe you could suggest a different debugging approach, ie. print statements around every mysql_query() or something else. Its hard to find a bug in a program that works (in IE anyway). Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/98325-unwanted-insert-after-doing-a-mysql-update-from-a-firefox-session/#findComment-503274 Share on other sites More sharing options...
dave905 Posted March 28, 2008 Author Share Posted March 28, 2008 Well I've given up on this...I've already taken too much time. I thank everyone for their help and suggestions. The fact that it works fine in IE makes me believe that the bug is not mine. The extra records don't interfere with the processing, so I'll just do a manual purge whenever there are too many of them. Quote Link to comment https://forums.phpfreaks.com/topic/98325-unwanted-insert-after-doing-a-mysql-update-from-a-firefox-session/#findComment-503511 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.