[SOLVED] Retrieving most recent data

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
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

[SOLVED] Retrieving most recent data

Post by Steveo31 »

Heyo.. have a lil problem with my script:

Code: Select all

<?php
$sql = " SELECT body, title FROM articles WHERE DAYOFMONTH( NOW( ) - INTERVAL 10 DAY )";
$query = mysql_query($sql);
while($row = mysql_query($query)){
echo $row['title'];
echo $row['body'];
}
?>
This code works in PhpMyAdmin, but not in PHP. No errors, no nothin, not even the data.

I'm not sure where the error is, but am I missing something?
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Wow, I'm not very smart. I used while($row=mysql_query) instead of while($row=mysql_fetch_assoc).

I'm going to leave it here for those who are interested.
Post Reply