Delayed MySQL Results When Using PHP

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Toot4fun
Forum Commoner
Posts: 25
Joined: Wed Dec 10, 2003 11:44 am

Delayed MySQL Results When Using PHP

Post 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.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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");
Toot4fun
Forum Commoner
Posts: 25
Joined: Wed Dec 10, 2003 11:44 am

Post by Toot4fun »

Unfortunately, that didn't work either.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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?
Toot4fun
Forum Commoner
Posts: 25
Joined: Wed Dec 10, 2003 11:44 am

Post 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);
Post Reply