Forum Moderators: coopster

Message Too Old, No Replies

PHP not retrieving most recent info to display

...should be simple, but something's amiss

         

mcjohnson

5:38 pm on Jul 12, 2006 (gmt 0)

10+ Year Member



Hello friends>

I have a VERY simple situation where I am uploading articles to a database with a simple interface. It specifies date posted, title, summary, content, etc.

I am spitting the articles out onto the home page of the website (only the title and summary) but oddly, it seems to be retrieving old info. Here's the code to retrieve from the MySQL db:

$query = "select * from news_publish
order by datepost desc limit 7 ";

$results=mysql_query($query) or die (mysql_error());
while ($rows=mysql_fetch_array($results)) {
extract ($rows);
echo stripslashes("<b>$title</b>");
echo "<br>";
echo stripslashes($summary);
echo "&nbsp<a href='http://www.example.org/news1.php?news_id=$rows[news_id]'>";
echo "(more)";
echo "</a>";
echo "<br><br>";
}

It seems like the order by would be sufficient to display the most recent 7 titles.

BUT what is happening is, it's displaying articles that have since been deleted! I have verified that they are no longer in the DB and have refresh, even put a javascript force-refresh on the page.

Is this a cache problem? What might I do to make sure the PHP script goes straigh to the DB for the latest info, without passing go?

Thanks!

[edited by: jatar_k at 6:11 pm (utc) on July 12, 2006]
[edit reason]
[1][edit reason] examplified url [/edit]
[/edit][/1]

jatar_k

6:13 pm on Jul 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



almost sounds like they are pulling from an old table or you have another db somewhere

I would check the db and see what's there. If they are deleted in the table it is supposed to be using then my guess is that it isn't using that table. Testing db maybe still around? or a spare table you were using for a while?

mcjohnson

6:25 pm on Jul 12, 2006 (gmt 0)

10+ Year Member



Hmm, nope. I double checked. I've got it configured to connect to the one and only db and the table news_publish is really it. I'm looking at some other possible issues. Any other thoughts?

Pat

jatar_k

6:27 pm on Jul 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



and when you run this query from command line does it give you the same results

which makes me think, what are you managing your db with?

mcjohnson

6:43 pm on Jul 12, 2006 (gmt 0)

10+ Year Member



I am managing the db via PHPmyAdmin on the server. I am a little green when it comes to command-line db management. Are you referring to connecting via telnet and executing queries that way, or using PHP to manage?

Pat

jatar_k

6:49 pm on Jul 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



via telnet or ssh

even though phpmyadmin should give you the answer you want if your scripts are connecting to something different than phpmyadmin you won't know. I rely solely on command line when I am looking at things like this. I need to confirm what dbs are there, what tables and what is in those tables/dbs.

mcjohnson

11:26 pm on Jul 12, 2006 (gmt 0)

10+ Year Member



here's an interesting twist - when I re-uploaded index.php, it fixed the problem. So I know the script is connecting to the right database, but something wierd is happening to the PHP...I suspect it has something to do with a CMS program I am using inserting something that is corrupting it. Hmmmm...

I'll keep an eye on it. Thanks for the feedback!

Pat

eeek

9:54 pm on Jul 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



when I re-uploaded index.php, it fixed the problem

Your server isn't using the date of the file as the last modified date is it? I had that problem a long, long time ago.