Results 1 to 3 of 3

Thread: query says 0 but mysql_numrows returns 1?!?!

  1. #1
    Join Date
    Mar 2009

    query says 0 but mysql_numrows returns 1?!?!

    At my wit's end on this one...

    Every time I run this (with the querystring blank or set to some invalid text), the numrecs echo shows a value of 1 (and the code branches in that direction.) But in reality, there are ZERO records found.

    If I copy the echoed query from the screen and paste it into phpMyAdmin, it returns "0". Can anyone spot the problem?

    PHP Code:
    $query " SELECT COUNT(*) FROM main WHERE UserCode = '" $qs "' ";
    'querystring = "' $qs '"<br>query = "' $query '"<br>';
    $result mysql_query($query,$dblink) or die(mysql_error());
    $numrecs mysql_numrows($result);
    'numrecs = ' $numrecs;
    $numrecs 1) {

    //    INVALID USER

    echo 'Recs = 0';
    Header"Location: ./login.php" );

        } else {

    //    VALID USER
    . . . 

  2. #2
    Join Date
    Jun 2008
    Well, since you use
    there should always be exactly one record returned, the record containing the number of matches. That number may well be zero, but you have to check the actual value, not the number of rows returned, to find out.

  3. #3
    Join Date
    Mar 2009
    DOH! Thanks, Malgrim. (I feel like such an idiot! LOL)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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