SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2005
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Invalid MySQL result resource

    Here's my error:

    Warning: mysql_result(): supplied argument is not a valid MySQL result resource

    Here's my problem code:

    Code:
    // Write the query and execute
    $query = "SELECT id, (SELECT MIN(id) FROM portfolio_content WHERE id > curr.id) AS next, (SELECT MAX(id) FROM portfolio_content WHERE id < curr.id) AS prev FROM portfolio_content AS curr WHERE id = '$portfolio_id'";
    $result = mysql_query($query);
    
    // Put the results into variables
    $portfolio_prev_id = mysql_result($result, 0, "prev"); // error
    $portfolio_next_id = mysql_result($result, 0, "next"); // error
    It works fine on my local machine but pukes when I execute it on my hosting server. Anybody know what could be going wrong here? Thanks.

    Wayward780

  2. #2
    get into it! bigduke's Avatar
    Join Date
    May 2004
    Location
    Australia
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you're on a MySQL version below 4.1 then that query wouldn't work since lower versions don't support subqueries.
    Try running the query on the db before using it.

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2005
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sun of a gun, you're right! I took a peek at my phpMyAdmin at LunarPages and they're using 4.0.23. Boo! Thanks for your help.

    Wayward780

  4. #4
    SitePoint Evangelist ClickHeRe's Avatar
    Join Date
    Mar 2005
    Location
    Ottawa, Canada
    Posts
    580
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and use this with your queries

    if ( mysql_errno() > 0 ) {
    echo mysql_error();
    exit;
    }


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
  •