Dumps Posted March 8, 2007 Share Posted March 8, 2007 I have a strange problem that I can't figure out. This is my first attempt at a PHP/MYSQL app. I have a list of houses with associated details - eg. address, postcode etc and a picture. When the user enters the data they can upload a picture to the server. When a house has been uploaded a receipt is returned and the user can click to add another property or go to their 'home' page and view their properties. So far so good. On the 'home' page a user can click to edit or remove house details. If the user selects edit, the amendproperty.php page shows the fields and the picture associated with the house. If the user wants to change the picture they can select a new one and upload this over the old one. This works and I can see the actual picture on the server now shows the new one. After the edit the user gets a receipt stating that the house has been successfully edited. However, when the user returns to the home page sometimes the property does not show the new picture unless the page is manually refreshed. I'm puzzled as to why it sometimes works and sometimes doesn't?!?! Homepage: <?php //get all properties belonging to user $query = "SELECT P.propertyid, P.housename, P.address1, P.address2, P.address3, P.town, P.postcode, P.region, C.country, P.bedrooms, P.price, P.posted, P.lastupdate, P.picturename FROM properties P, countries C WHERE (P.countryid = C.countryID) AND owner = '" . $_SESSION['loginusername'] . "'"; //Open the database connection if (!($connection = @ mysql_connect($hostName,$username,$password))) showerror(); //Select the estate agents database if (! mysql_select_db($databaseName, $connection)) showerror(); //Run the query $result = mysql_query ($query, $connection) OR die(mysql_error()); //fetch into $row array while ($row = @ mysql_fetch_assoc($result)) { $template = new HTML_Template_ITX("./templates"); $template->loadTemplatefile("userproplist.tpl",true,true); $template->setVariable("PROPERTYID", $row['propertyid']); $template->setVariable("HOUSENAME", $row['housename']); $template->setVariable("ADDRESS1", $row['address1']); $template->setVariable("ADDRESS2", $row['address2']); $template->setVariable("ADDRESS3", $row['address3']); $template->setVariable("TOWN", $row['town']); $template->setVariable("POSTCODE", $row['postcode']); $template->setVariable("REGION", $row['region']); $template->setVariable("COUNTRY", $row['country']); $template->setVariable("BEDROOMS", $row['bedrooms']); $template->setVariable("PRICE", $row['price']); $template->setVariable("POSTED", $row['posted']); $template->setVariable("LASTUPDATE", $row['lastupdate']); $template->setVariable("PICTURE", $row['picturename']); $template->setVariable("PROPERTYID", $row['propertyid']); $template->parseCurrentBlock(); $template->show(); } ?> Link to comment https://forums.phpfreaks.com/topic/41791-solved-update-does-not-show-until-manual-refresh/ Share on other sites More sharing options...
paul2463 Posted March 8, 2007 Share Posted March 8, 2007 this may be a browser setting for the user not a problem with your system, if the user has not set the browser to get new information on every visit to the page then it will pull the old information from the cache. and only refresh the cache when it is told to. hope that makes sense Link to comment https://forums.phpfreaks.com/topic/41791-solved-update-does-not-show-until-manual-refresh/#findComment-202665 Share on other sites More sharing options...
Dumps Posted March 8, 2007 Author Share Posted March 8, 2007 I thought it may have something to do with the cache. Any idea how I might go about fixing this so the updated picture is always displayed? Link to comment https://forums.phpfreaks.com/topic/41791-solved-update-does-not-show-until-manual-refresh/#findComment-202673 Share on other sites More sharing options...
interpim Posted March 8, 2007 Share Posted March 8, 2007 you could use javascript to auto refresh the page... that may work, but I don't know any javascript Link to comment https://forums.phpfreaks.com/topic/41791-solved-update-does-not-show-until-manual-refresh/#findComment-202677 Share on other sites More sharing options...
paul2463 Posted March 8, 2007 Share Posted March 8, 2007 you cant change the settings on a users browser, what you could do is on the receipt you send them to say the change has taken place you can put a warning with it saying "you have changed the picture, if you have not set your browser up to collect new information on every visit then refresh the page to see the changes, thanks" that would work Link to comment https://forums.phpfreaks.com/topic/41791-solved-update-does-not-show-until-manual-refresh/#findComment-202679 Share on other sites More sharing options...
paul2463 Posted March 8, 2007 Share Posted March 8, 2007 or as the other person said you could always have the following <script language="text/javaScript"> <!-- function refresh() { window.location.replace( sURL ); } //--> </script> //--> then have this in the body tags <body onload="refresh()"> then every time a user goes to that page it is automatically refreshed for them Link to comment https://forums.phpfreaks.com/topic/41791-solved-update-does-not-show-until-manual-refresh/#findComment-202684 Share on other sites More sharing options...
Dumps Posted March 8, 2007 Author Share Posted March 8, 2007 Will look into the javascript option, although I'm a bit confused as to why the update would work sometimes but not always....? Anyway, thanks a lot. Link to comment https://forums.phpfreaks.com/topic/41791-solved-update-does-not-show-until-manual-refresh/#findComment-202687 Share on other sites More sharing options...
Dumps Posted March 8, 2007 Author Share Posted March 8, 2007 A colleague has presented another solution. Appending a randomly created number to the end of the picture eg. <img src="./images/{PICTURE}?sdjfs={myrand}"/> fools the browser into thinking that it is a different image and refreshes accordingly. A bit of a cadge, but works just fine. Link to comment https://forums.phpfreaks.com/topic/41791-solved-update-does-not-show-until-manual-refresh/#findComment-202707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.