Page 1 of 1

Problems with PHP and MySQL

Posted: Mon Mar 13, 2006 11:39 am
by Templar
Here's the script.

Code: Select all

Function headlines() {
  $today = date("Y-m-d");
  $query = "SELECT * FROM news WHERE StoryRunStart < $today AND StoryRunEnd > $today ORDER BY StoryDate DESC LIMIT 5";
  $result = mysql_query($query) or die ("Query Failed! Query:<br>". $query);
  
  while($stories = mysql_fetch_object($Result, MYSQL_ASSOC)) {
    print("
            <b>$stories->StoryHeadline</b><br><i>$stories->StoryDate</i><br><br>$stories->StoryIntro<br><br>
            [ <a href='news.php?action=SingleStory&StoryID=$stories->StoryID'>Read More</a> ]<br><br>
    ");
  }
  print("
            <a href='news.php?action=Archives'>News Archives</a><br><br>
  ");
}
Basically, I have some news articles in a database and I want to pull some of the information out. The error I am getting on my web page is:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/content/d/a/v/david/html/functions.php on line 15
Any ideas?

Posted: Mon Mar 13, 2006 12:16 pm
by feyd
$Result vs $result case issue ;)

and $today should be in quotes inside your query string.

Posted: Mon Mar 13, 2006 3:48 pm
by Templar
many thanks.