Advanced Search

Results 1 to 8 of 8

Thread: Problem "mysql_result(): Unable to jump to row 0"

  1. #1
    Join Date
    Jun 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem "mysql_result(): Unable to jump to row 0"

    Hello,
    I am using the following code, and i get an error on the last statement (last line). The error only shows up for the entries that don't exist in the 815SF_attachments table.

    Error is -
    Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 16 in ...index.php on line 25

    Any ideas? It's probably something stupid that I'm overlooking.


    PHP Code:
    $select "SELECT ID_MEMBER FROM 815SF_themes WHERE variable = 'cp1' ORDER BY ID_MEMBER";
    $query mysql_query($select)or die(mysql_error());

    while(
    $list mysql_fetch_object($query))
    {
    $id $list->ID_MEMBER;


    $sql "SELECT value FROM 815SF_themes WHERE ID_MEMBER = " $id " AND variable = 'cp1'";
    $res mysql_query($sql);
    $flname mysql_result($res0);

    $sql "SELECT filename FROM 815SF_attachments WHERE ID_MEMBER = " $id
    $res mysql_query($sql);
    $avatar mysql_result($res0); 

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    i am not sure if this is causing the error or not, but you forgot to put ASC or DESC on the order by..

    also in your bottom two queries. This isnt the error that was given, but if you dont encapsulate the ID_MEMBER in quotes, sometimes its read as a column and not a value
    Code:
    $sql = "SELECT value FROM 815SF_themes WHERE ID_MEMBER = '" . $id . "' AND variable = 'cp1'"; 
    ...
    $sql = "SELECT filename FROM 815SF_attachments WHERE ID_MEMBER = '" . $id ."'";

  3. #3
    Join Date
    Jun 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you for the corrections.. However, the problem still exists. It has something to do with the fact that it is looping through the tables looking for entries based on MEMBER_ID, and some of the MEMBER_ID's DON'T have an entry in the 815SF_attachments table, and it doesnt know how to fall out without giving the error

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    Use @ to suppress errors and an if to see if it works.

    Usually, mysql results return multiple rows. When doing this, a while statement is used:
    while ($row = mysql_fetch_array($result)) { //do stuff; }

    That will go through //do stuff; for the number of rows present in $result, whether that is 10, 5, 1, or even 0*.
    (*I think this might give an error, but I don't remember that being the case.)

    In your case, it seems you will never want more than one result returned, even if more than one matches exist in the database, so I suggest the same idea, but with an if statement.

    You can do this simply by:
    if ($row=@mysql_fetch_assoc($result)) { //do stuff; }
    And, just in the case a row doesn't exist:
    else { echo "sorry, no record exists, etc."; }

    As for a MEMBER_ID not existing, that is entirely a fault of the database setup and will not be fixed by any programming/functions. MySQL's use is finite-- you must determine a reliable method for finding the desired data sets-- no way around that.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jun 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks.. the @ was all that I needed. it is intentional that some of the member id's are not on that table.. so all i needed was for it to ignore the fact that they weren't there.. Thanks a lot!!!

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    No problem.

    Also, note that @ doesn't change the meaning of a function. It will still be true or false, but the @ simply suppresses all errors. So you can still use if (@function()), and that won't change the result, but just not display an error.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Also you could use this instead of @
    if ($variable == null) {
    echo "id not exsist"

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,629
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    mantasmatusevicius:

    Please check the dates before replying to threads.
    The last post to this thread was over five years ago, and the original poster had already found and accepted a solution.


    (In addition, if( $variable == null ) won't help with the stated goal: handling the problem while suppressing the error.)

    I'm closing this thread. If you (or anyone) has similar questions, please start a new thread.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

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
  •