Problems with PHP and MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Templar
Forum Newbie
Posts: 2
Joined: Mon Mar 13, 2006 11:36 am

Problems with PHP and MySQL

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$Result vs $result case issue ;)

and $today should be in quotes inside your query string.
Templar
Forum Newbie
Posts: 2
Joined: Mon Mar 13, 2006 11:36 am

Post by Templar »

many thanks.
Post Reply