So, basically, here’s the situation.
I am currently writing a news infobox in flash and php using xml as the data-handler. It basically gets the xml to populate the news items from a database, which is a mySQL db with 3 fields, the primary key, news_id, is on auto_increment.
My problem is that sometimes, when i check the news, the most current item will not show up. Sometimes it will be there, and sometimes it won’t, at random. Everything else works great.
I isolated the problem so that I’m sure it has something to do with either this section of the php code or my server. When i test this code with simple echo commands it will sometimes show up with the most current news_id, and sometimes the previous one.
[AS]
$conn = mysql_connect($localhost, $login, $password);
if(!$conn){die(“Authentication Connection error”); }
mysql_select_db($db, $conn) or die(“Cannot connect to database”);
$query_id = mysql_query(“SELECT max(news_id) AS top_article FROM news ORDER BY news_id”);
while($max_id_temp = mysql_fetch_array($query_id)){
$article_num = $max_id_temp[‘top_article’];
$article_num++;
$max_id = $article_num;
echo $max_id . “<br/>”;
}
[/AS]
ARGH!!! Help!!!
It might have something to dow with the way the SELECT max() functions, or heaven knows what else. If you have any experience with this problem and have a suggestion I’d love to hear it, cuz i just can’t figure it out.
Thank you all who respond in advance,
Edit* oh, and the problem seems to completely disappear after about an hour. What’s that all about? Is it my server caching the query? If so, why does it sometimes display the correct value and sometimes not? CONFUSED. =*(
–EP