Database Woes, x-posted in php...

    Date: 12/29/04 (MySQL Communtiy)    Keywords: php, mysql, html, database, sql

    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...

    Source: http://www.livejournal.com/community/mysql/45003.html

« My brain hurts... || MySQL support for AMD64 »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home