Jump to content

Sql Query Not Updating In Ie


dhoult
 Share

Recommended Posts

I hope I'm asking this in the correct forum...There is a form on my website where you enter information, it stores it in the database, takes you to another page where you enter more info, etc.When you click the "back" button on a page (not the browser back button), it goes to the previous page, loads your information from the database and places it into the form so you can then modify it.  If you submit that form, it updates the info in the database.This works fine.  However, the problem I have is when you go back to the same page a second time, it does not display the modified information, but rather it shows the original info. THIS IS ONLY AN ISSUE WITH IE.  It displays the updated info like it should in Firefox and Chrome.I have checked the database and it gets updated every time without fail.  I have checked the variables that store the information from the SQL query and they're empty until the call on the webpage.  So I really have no clue how IE is retrieving the original data when it no longer exists in the database.I am using Access 2003 for my database and Sambar as my web server.Any ideas? Thanks!!

Link to comment
Share on other sites

That's just an IE issue, it's using cached form data that it will automatically fill in again if you hit the back button. Other browsers use the most recent form data, apparently IE uses the oldest for whatever reason. That's not something you can change, IE will do that regardless. You don't really have any control at all when people use the back button.

Link to comment
Share on other sites

Could you detect that the visitor has come back to the page, like by counting their visits, and use PHP to echoa meta refresh? Would that even have the right effect in IE?

Link to comment
Share on other sites

Normally when you hit the back button the browser doesn't even go back to the server, you'd never even know they hit back and wouldn't be able to change the page they see even if you were aware. It just loads the page from the cache, recently browsers have also started filling in form information if there was any.

Link to comment
Share on other sites

Hm. Theoretically, can you capture the back button/Alt+left cursor event and use that to throw a refresh? Might not be worth it, but can you?

Link to comment
Share on other sites

I don't think hitting the back button fires a Javascript event (other than possibly a normal unload event for the current page, but I'm not even sure about that), it's just part of the browser interface.You may be able to disable caching on the page though, which may force the browser to always request it from the server.

Edited by justsomeguy
Link to comment
Share on other sites

That's just an IE issue, it's using cached form data that it will automatically fill in again if you hit the back button. Other browsers use the most recent form data, apparently IE uses the oldest for whatever reason. That's not something you can change, IE will do that regardless. You don't really have any control at all when people use the back button.
The back button I'm talking about is not for the browser. I have a "back" button next to my "submit" button. All the back button does is run a script that loads the previous form into a <div> container in the window. That form will query the database to see if the person already entered information. If there is a record for that form, it will fill in all the recorded entries. With IE, when I run the "SELECT" statement, all the returned data is old, even though when I look in the database the old entries are not there anymore. Edited by dhoult
Link to comment
Share on other sites

Okay, I think I fixed it. Apparently, IE was doing something with the database connection like not releasing it. So the new data got sent to the database, but IE couldn't access the new information yet. I guess the old info was still stored in a buffer, and querying the database again used that buffer instead of the new info.That's just the way I see it. Anyway, I played around with a few numbers like the "query timeout" in my server configurations, and now it seems to work. Hopefully it stays that way ::crosses fingers::Thanks for your ideas.Btw, I've had too many problems in general programming this website for IE. It's been so much easier in the other two.

Edited by dhoult
Link to comment
Share on other sites

Now it's not working again..... grrrrr

Well, a browser isn't going to affect what happens with the SQL server, so there has to be some browser-specific aspect somewhere in the process to retrieve the data. It's hard to say without seeing the details though.
Here's a sample:<form action="confirmOrder.stm" method="post" enctype="multipart/form-data" name="order1" id="order1"> <table id="orderForm" border="0" cellpadding="0" cellspacing="10"> <tr> <td id="label">First Name</td> <td><span id="spryFirstName"> <input type="text" name="firstName" id="firstName" tabindex="1"/><br /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> <td id="label">Last Name</td> <td><span id="spryLastName"> <input type="text" name="lastName" id="lastName" tabindex="2"/><br /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr></table><input type="submit" name="submit" value="Submit"><input type="button" name="back" id="back" value="<- Back" onClick="loadPage('order.stm?ID=<RC$ID>&back=yes', 'order')"> </form>...// <RCQdata sql="SELECT * FROM orders WHERE OrderID = RC$ID"><RCFdata><RCif RCDdata.1 ! NULL> document.getElementById("firstName").value = '<RCDdata.2>' document.getElementById("lastName").value = '<RCDdata.3>'<RCendif> Edited by dhoult
Link to comment
Share on other sites

Print out the RC$ID value that you're using to see what it is, make sure that when you go back the ID is correct. I'm not sure what DBMS you're using, but maybe the database is caching the data.
I've checked all the variables, and they all seem correct. But if the database is caching the values, why would I only have the problem in IE?
Link to comment
Share on other sites

I don't know, it doesn't make sense that the user agent would have any effect on what happens on the server. If your database library is taking the user agent into effect I'm not real sure how to fix that. Maybe check with the documentation for the database library you're using.

Link to comment
Share on other sites

So I noticed that when I hit my back button, or even when I hit submit again, and the pages get loaded, according to the server logs the sql "select" statements don't get executed, yet the variables are still assigned (the old values). In Firefox and Chrome all the statements are executed.

Link to comment
Share on other sites

If it is a cache problem you could try appending to the url a random variable. Instead of justonClick="loadPage('order.stm?ID=<RC$ID>&back=yes', 'order')you could create a timestamp and add it to the url$time=time();onClick="loadPage('order.stm?ID=<RC$ID>&back=yes&random=$time', 'order')As IE will not have this url stored in cache it should always go to the server for a new page. You don't need to do anything with random, just use it to generate a previously unknown url.

Link to comment
Share on other sites

If it is a cache problem you could try appending to the url a random variable. Instead of justonClick="loadPage('order.stm?ID=<RC$ID>&back=yes', 'order')you could create a timestamp and add it to the url$time=time();onClick="loadPage('order.stm?ID=<RC$ID>&back=yes&random=$time', 'order')As IE will not have this url stored in cache it should always go to the server for a new page. You don't need to do anything with random, just use it to generate a previously unknown url.
Doesn't work :)
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...