Results 1 to 11 of 11

Thread: [RESOLVED] MYSQL Num Rows Problem - Help Needed

  1. #1

    Thread Starter
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Resolved [RESOLVED] MYSQL Num Rows Problem - Help Needed

    why do i get an error when i run this code?

    PHP Code:
    $sql "SELECT * FROM tbl_Quotes";
    $rs mysql_query($sql);
    $numrows mysql_num_rows($rs); 
    the error is below
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

    thanks
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

  2. #2

    Thread Starter
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: MYSQL Num Rows Problem - Help Needed

    anyone please???
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: MYSQL Num Rows Problem - Help Needed

    Please don't bump your posts after such a short time.

    You can dump the last error message generated by MySQL by using the mysql_error() function.

    PHP Code:
    $sql "SELECT * FROM tbl_Quotes"
    $rs mysql_query($sql);
    if (
    mysql_errno()) {
      echo 
    mysql_error();

    Last edited by penagate; Mar 19th, 2006 at 11:02 PM.

  4. #4
    Lively Member
    Join Date
    Nov 2005
    Posts
    72

    Post Re: MYSQL Num Rows Problem - Help Needed

    Quote Originally Posted by modpluz
    why do i get an error when i run this code?

    PHP Code:
    $sql "SELECT * FROM tbl_Quotes";
    $rs mysql_query($sql);
    $numrows mysql_num_rows($rs); 
    the error is below
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

    thanks
    use this one.
    PHP Code:
    $sql "SELECT * FROM tbl_Quotes";
    $rs mysql_query($sql) or die(mysql_error());
    $numrows mysql_num_rows($rs); 

  5. #5
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: MYSQL Num Rows Problem - Help Needed

    Quote Originally Posted by penagate
    Please don't bump your posts after such a short time.
    Got there before me

    uttam die should be only for debugging, as it will stop the execute of the script, for live scripts use penagates method of displaying MySQL errors.

  6. #6
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: MYSQL Num Rows Problem - Help Needed

    it errors because that function does not exist it is:

    mysql_numrows() not mysql_num_rows

    so...

    Code:
    $row_count = mysql_numrows($result);
    Chris

  7. #7
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: MYSQL Num Rows Problem - Help Needed

    the182guy, I use mysql_num_rows all the time to find out how many records have been returned from my query without it ever displaying an error.

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: MYSQL Num Rows Problem - Help Needed

    When in doubt, refer to the manual!
    Quote Originally Posted by [url=php.net/mysql_num_rows]mysql_num_rows[/url]
    Note: For downward compatibility, the following deprecated alias may be used: mysql_numrows()

  9. #9
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: MYSQL Num Rows Problem - Help Needed

    who ever reads a manual these days!!

  10. #10
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: MYSQL Num Rows Problem - Help Needed

    Quote Originally Posted by lintz
    the182guy, I use mysql_num_rows all the time to find out how many records have been returned from my query without it ever displaying an error.
    If this would try the error message he would have seen first would be, Fatal error: Call to undefined function.

    It's not working because their is a problem with his query. This is not returning a valid resource that mysql_num_rows requires. Check with msql_error is your best bet.

    Quote Originally Posted by lintz
    who ever reads a manual these days!!
    Like my lecturer keeps telling us RTFM

  11. #11
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: MYSQL Num Rows Problem - Help Needed

    LMAO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width