SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql error - "Offset 0 is invalid for MySQL result index 6"

    I am trying to rpint the number of records found.

    Here's the error:

    Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 6 (or the query data is unbuffered) in /..../aresults.php on line 154


    mysql_select_db($dbread, $read);
    $query_rsCSUM = "SELECT fID, Count(cID) FROM car WHERE DATE_SUB(CURDATE(),INTERVAL 12 MONTH) <= dateC GROUP BY fID";
    $rsCSUM = mysql_query($query_rsCSUM, $read) or die(mysql_error());
    $row_rsCSUM = mysql_fetch_assoc($rsCSUM);
    $totalRows_rsCSUM = mysql_num_rows($rsCSUM);



    Then later in the page, here's the snippet throwing the error:


    <?php
    mysql_data_seek($rsCSUM, 0); //LINE 154 causing the problem
    $num_C = 0;
    do {
    if ($row_rsCSUM['facilityID']==$row_rsSearchF['ID']){
    $num_CAR = $row_rsCSUM["Count(cID)"];
    }
    } while ($row_rsCSUM = mysql_fetch_assoc($rsCSUM));loop
    echo $num_C; //print the number of records found
    ?>
    signature

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Cyberia
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This looks like it comes from Dreamweaver I think that you query is wrong and it returns nothing. You have $num_C outside your do...while loop, but $num_CAR inside? Try rewriting it like this for start:

    PHP Code:
    <?php
    mysql_select_db
    ($dbread$read); 
    $query_rsCSUM "SELECT fID, Count(cID) FROM car WHERE DATE_SUB(CURDATE(),INTERVAL 12 MONTH) <= dateC GROUP BY fID";
    $rsCSUM mysql_query($query_rsCSUM$read) or die(mysql_error());
    $totalRows_rsCSUM mysql_num_rows($rsCSUM);

    echo 
    "Total rows returned from query: " $totalRows_rsCSUM // for debugging only -- turn off if query works!

    ?>
    ... 
    <?php
    $num_CAR 
    0;
    while ( 
    $row_rsCSUM mysql_fetch_assoc($rsCSUM) )

      if ( 
    $row_rsCSUM['fID']==$row_rsSearchF['ID'] ) 
      {
        
    $num_CAR += $row_rsCSUM["Count(cID)"];
      }
    }
    echo 
    $num_CAR//print the number of records found
    ?>

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that worked - thanks!

    It is dreamweaver generated and I think I'm at a point where I am ready to code without the auto-generate capabilities of DW but it really speeds things up.

    Any thoughts about what I should lok at next? I've thought about moving to Zend Studio.

    I really to move toward efficiency and speed of development. Both come with more knowledge.
    signature

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Cyberia
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, Dreamweaver is great for rapid development and prototyping. But time comes when you hit it's limitations.

    And by all means, do try Zend Studio. It doesn't write code instead of you like DW does and interface is kind of uglish (Java application -- 'nuff said). But it has features like debugger, templates, code completion, and syntax highlighting that will tremendously increase your productivity. And of course, you can continue to use DW for HTML design.


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
  •