Page 1 of 1

Delayed MySQL Results When Using PHP

Posted: Wed Dec 10, 2003 11:44 am
by Toot4fun
I have a PHP page that is supposed to read and display all of the lines in a MySQL table. The page itself works fine, but the displayed results do not match what is actually in the table. If I browse the table using PHPMyAdmin, the newly added lines are shown. But if I go to the PHP page, these newly added results do not appear, even after refreshing. It is not until a few hours later that the lines are finally displayed by the PHP page.

I've already tried adding
header("Cache-Control: no-cache");
and
header("Pragma: no-cache");
but that didn't seem to help.

I'm relatively new to PHP and MySQL, but not to front end/database integration (I used to use ASP and MS SQL). But I've never seen anything like this. Any help would be greatly appreciated.

Posted: Wed Dec 10, 2003 6:36 pm
by JAM
Wierd problem. Try using the following and see if that gives you more ideas:

Code: Select all

// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
 
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");

Posted: Wed Dec 10, 2003 7:03 pm
by Toot4fun
Unfortunately, that didn't work either.

Posted: Wed Dec 10, 2003 7:12 pm
by infolock
want to post your sql query you are using, and maybe how you are calling the results?

is there anything else on the page that is preventing it to be refreshed and updated?

Posted: Wed Dec 10, 2003 8:02 pm
by Toot4fun
Here's the code I'm using to connect, as well as my SQL query:


$db_link = mysql_connect("[hostname]", "[username]", "[password]") or die("There was a problem connecting to the database.");
$status = mysql_select_db("[database]", $db_link);

if ($status) {
$sql_query= "SELECT * FROM tblSubprofile ORDER BY ID DESC";
$result = mysql_query($sql_query, $db_link);
$row = mysql_fetch_row($result);
$rowsReturned = mysql_num_rows($result);

Code: Select all


$status = mysql_close($db_link);