SQL Select Issue After Update

Hello all,

I have put together a simple php site that uses a mysql database to record game and player records

Whenever I attempt to update or insert a record, the database does reflect the change, however when I attempt to run the select query a second time, it returns a result set as if the update or insert never took place. The updates and inserts are permanent so it doesn’t seem like a rollback issue.

When I clear the web browser’s cache and cookies and reload the page, the select statement does return the updated records, however I’m using the following headers so I’m not quite sure what type of caching issues might be responsible:

Cache-Control => no-cache, no-store, must-revalidate
Pragma => no-cache
Expires => 0

Upon page load, selectplayers is called and will return player A and B. I then call deleteplayer to remove B and the record is indeed removed from the database. I call selectplayers a second time by clicking a button and it still returns player A and B. If I refresh the page, it still returns player A and B. If I clear the cache and refresh the page, it returns only player A.

[php]function selectplayers() {
$db = new db(“mysql-t”,“user”,“password”,“database”);
$id = $db->escape($_REQUEST[“id”]);
$db->execute(“SELECT name FROM players WHERE id=$id”);
$db->close();
//echo result set to page
}

function deleteplayer() {
$db = new db(“mysql-t”,“user”,“password”,“database”);
$id = $db->escape($_REQUEST[“id”]);
$db->execute(“DELETE FROM players WHERE id=$id”);
$db->close();
}[/php]

My php knowledge is pretty limited, so any suggestions would certainly be appreciated. Thanks! :slight_smile:

Sounds like it’s a browser issue, which browser are you using?

Try using

[php]

[/php]

It would be helpful if you could post all the code and an sql dump with a few sample records.

It sounds like its not actually deleting any records from the table. When you delete the record, have phpmyadmin up so you can take a physical look at the db table afterwards, make sure its really deleting it.

Sponsor our Newsletter | Privacy Policy | Terms of Service