Jump to content

Unwanted INSERT after doing a MySQL UPDATE from a Firefox Session


Recommended Posts

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="";

 

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.

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...

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.

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 ;)

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,

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.