SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2004
    Location
    Philadelphia
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting an odd warning when doing a news listing

    I keep getting the following and can't understand why it's happening

    Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in /home/sawken/public_html/circanews.php on line 32

    I am working on a dynamic news page that displays a set number of entries from a database (up to 10). I am on the verge of a breakthrough with my coding/using Dreamweaver and if anyone could help they would have my eternal thanks.

    The result page is at http://sawken.com/circanews.php It displays only the one record and there are two in the database. Please let me know if you need more info.

    The code I am using is below:
    <?php require_once('Connections/Circa.php'); ?>
    <?php
    $maxRows_rsNews = 10;
    $pageNum_rsNews = 0;
    if (isset($_GET['pageNum_rsNews'])) {
    $pageNum_rsNews = $_GET['pageNum_rsNews'];
    }
    $startRow_rsNews = $pageNum_rsNews * $maxRows_rsNews;

    mysql_select_db($database_Circa, $Circa);
    $query_rsNews = "SELECT * FROM tblNews ORDER BY newsDate DESC";
    $query_limit_rsNews = sprintf("%s LIMIT %d, %d", $query_rsNews, $startRow_rsNews, $maxRows_rsNews);
    $rsNews = mysql_query($query_limit_rsNews, $Circa) or die(mysql_error());
    $row_rsNews = mysql_fetch_assoc($rsNews);

    if (isset($_GET['totalRows_rsNews'])) {
    $totalRows_rsNews = $_GET['totalRows_rsNews'];
    } else {
    $all_rsNews = mysql_query($query_rsNews);
    $totalRows_rsNews = mysql_num_rows($all_rsNews);
    }
    $totalPages_rsNews = ceil($totalRows_rsNews/$maxRows_rsNews)-1;

    mysql_free_result($rsNews);
    ?>
    <?php do { ?>
    <p><?php echo $row_rsNews['newsDate']; ?></p>
    <p><?php echo $row_rsNews['newsTitle']; ?></p>
    <p><?php echo $row_rsNews['newsDesc']; ?></p>
    <p><?php echo $row_rsNews['newsLink']; ?></p>
    <?php } while ($row_rsNews = mysql_fetch_assoc($rsNews)); ?>

  2. #2
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Parry Sound, ON
    Posts
    725
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dispose of this:
    PHP Code:
    mysql_free_result($rsNews); 

  3. #3
    SitePoint Member
    Join Date
    Oct 2004
    Location
    Philadelphia
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awesome, thank you very, very much!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •