#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,688
    Rep Power
    171

    Cache? I can see database updates after refreshing!


    Hi;

    When I update the database I need to refresh the page to see the changes. Why is that? How can I fix that?

    I havent set cache anywhere! I added this to the code. But it did not make any difference.
    PHP Code:
    <?php 
    $this
    ->output->set_header('Last-Modified: ' gmdate("D, d M Y H:i:s") . ' GMT');
    $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    $this->output->set_header('Pragma: no-cache');
    $this->output->set_header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    ?>
    And this to <head>
    html Code:
    <meta http-equiv=“pragma” c />
    <meta http-equiv=“Expires” c />
    <meta http-equiv=“CACHE-CONTROL” c />
    Jesus loves you
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,294
    Rep Power
    9400
    You're probably running the queries before you've done the updates. Causality doesn't let you get changed data before you've changed it.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,026
    Rep Power
    377
    totally confused here. If you update something in the database, you need to refresh so queries RE-RUN again to get the right counts etc?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    5
    Rep Power
    0
    I'm a l;ittle confuesed too. Is it possible that you could use Ajax to give you pseudo live results ?
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    We need to see the code. Without the concrete code, it's all just speculation.

    What requinix says is that you might have fetched the data you wanna display before you did the update. In that case, you obviously see the old data. If you wanna see the updated data immediately, you must do the update on top of the script.

    Comments on this post

    • MeccaOz agrees
    • SimonJM agrees : ... plus a nice, new avatar :)
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  10. #6
  11. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,688
    Rep Power
    171
    Hi;

    I update in one page and then show a link on screen for users to click and see the results.

    Update :
    PHP Code:
    $this->vr=$this->input->post('vr');
    $this->nn=$this->input->post('n');
          
    foreach(
    $this->input->post('x_id') as $count => $row)
        {
            
    $this->posted_data[] = array(
              
    'vr'=>$this->vr[$count],
              
    'nn'=>$this->nn[$count]);
        }

    $this->db->update_batch('thx_daily'$this->posted_data'x_id'); 

    In the next page retrieve:
    PHP Code:
    $this->load->model('model_thx');    
    $data_results['thx'] = $this->model_thx->load_thx_vouchers($id); 

IMN logo majestic logo threadwatch logo seochat tools logo