SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: wierd error

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    wierd error

    wierd error? When I use this:
    mysql_data_seek ($result,0);

    I get this error:
    Warning: Offset 0 is invalid for MySQL result index 2 in /www/welcometovernon/coupons/news/news_admin.php3 on line 131

    any ideas?

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I can't think of any reason why you would want to use that function. But, if you think you must, then check out www.php.net for the details of the function, including the return type. Also, the user comments usually cover any troublesome aspects of the function. In fact, the last user comment looks like it addresses your error.
    Last edited by 7stud; Jun 3, 2001 at 12:22.

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with 7stud here, is there a specific reason why you want to use this? Is it because you want to loop through your resultset twice? If so, I suggest storing the results in an array then looping through that twice something like:

    PHP Code:
    <?
    $result 
    mysql_query("SELECT field1, field2, field3 from tablename");
    while(
    $row mysql_fetch_array($result)) {
        
    $array[] = array("field1" => $row["field1"], 
                         
    "field2" => $row["field2"], 
                         
    "field3" => $row["field3"]
                         );
        }

    //First loop:
    foreach($array as $key => $val) {
        print 
    $array[$key]["field1"] ." - "$array[$key]["field2"] ." - "$array[$key]["field3"] ."<br>";
        }

    //Reset the array
    reset($array);

    //Second loop:
    foreach($array as $key => $val) {
        print 
    $array[$key]["field1"] ." - "$array[$key]["field2"] ." - "$array[$key]["field3"] ."<br>";
        }


    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •