MySQL error

Discussion in 'OT Technology' started by GTS4eva, Jan 30, 2006.

  1. GTS4eva

    GTS4eva New Member

    Joined:
    Feb 20, 2005
    Messages:
    272
    Likes Received:
    0
    Location:
    California
    So I need some help,

    I get this error :
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in blablabla

    Heres the part of the code they say messed up

    PHP:
    function numrows($sqllump)
    {
    global 
    $debug$debuginfo$mysqlloosetime;
    $b microtime();
    $num mysql_num_rows($sqllump);
    $mysqlloosetime += microtime() - $b
    if ((
    $debug>0) && ($debug<4))
    {
    if (
    $debug == 2)$debuginfo .= "<p>Number of rows is $num for $sqllump"mysql_error() ."</p>"
    else echo 
    "<p>Number of rows is $num for $sqllump"mysql_error() ."</p>"
    }
    return 
    $num;
    }
    the line of
    PHP:
    $num mysql_num_rows($sqllump);
    is said to have something wrong..

    Whats the problem? I can't figure it out!!

    Thanks
     
  2. dk01

    dk01 Awwwwww..... OT Supporter

    Joined:
    Mar 1, 2005
    Messages:
    3,178
    Likes Received:
    0
    Location:
    All up in your interwebsnet.
    Can you post what the sql query would be? Has sqllump already executed a valid sql query at this point?
     
  3. dk01

    dk01 Awwwwww..... OT Supporter

    Joined:
    Mar 1, 2005
    Messages:
    3,178
    Likes Received:
    0
    Location:
    All up in your interwebsnet.
    Remember if you have executed a SELECT statement you must use mysql_num_rows(). If you are doing an UPDATE, INSERT or DELETE statement then you should use mysql_affected_rows().

    Also remember that the variable inside mysql_num_rows() has to be a valid MySQL result produced from executing a SELECT statement with mysql_query().
     
  4. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    You have a problem with the SQL query, *not* the php portion. When I get errors like this I usually print out the sql query -- it usually makes the problem a bit mroe obvious.
     

Share This Page