Douglas A. Maske (herstarcatcher) wrote in mysql,
Douglas A. Maske
herstarcatcher
mysql

  • Mood:

Database Woes, x-posted in php...

Ok, I figured something out.

When I run the mysql query at a mysql or phpmyadmin prompt I get the proper results...

SELECT * FROM fff_news WHERE month(date)=month(now()) and year(date)=year(now()) ORDER BY date DESC

But when I throw this into an array with php's mysql_fetch_array or mysql_fetch_row everything will display except for the top entry which would be the last date entered into the database. If I add a new entry for yesterday, it won't show until I add a second entry for yesterday(and then that one won't show) or a new entry for today(which won't show).

Why is php mangling my query like this, it's rather simple...

snip...(and I cut out my html which semagic won't let me display as code anyway...)

} else {

$sql = 'SELECT * FROM fff_news WHERE month(date)=month(now()) and year(date)=year(now()) ORDER BY date DESC';
$result = mysql_query($sql);
$row = mysql_fetch_array($result);

if (!$result) {
echo("

Error performing query: " . mysql_error() . "\n");
exit();
}

while ($row = mysql_fetch_array($result)) {
echo $row[date];
echo $row[pagetitle];
echo $row[content];

}

...snip...

Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 4 comments