Jump to content

[SOLVED] Update does not show until manual refresh


Dumps

Recommended Posts

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


?>

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

 

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

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

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.

Archived

This topic is now archived and is closed to further replies.

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