SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry start ur day with an annoying simle query

    PHP Code:
    $sql "SELECT * FROM member WHERE EmailAddress = '".$uid."' AND Password = md5('".$pwd."') AND Activated='YES' ";

    // retrieve number of rows resulted 

    mysql_query($sql)or die(mysql_error());
    echo 
    $num=mysql_num_rows($sql); 
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in auth.php on line 17

    copy the query to the phpmyadmin it works fine
    then why the mysql_num_rows doesnt work i saerched the net .. couldnt find enough help
    the query is 100% right ..
    why this is coming up and rewing my day :S

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $result mysql_query($sql)or die(mysql_error());
    $num mysql_num_rows($result);
    echo 
    $num

  3. #3
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $sql = "SELECT * FROM member WHERE EmailAddress = '$uid' AND Password = md5('$pwd') AND Activated='YES' ";

    shld work!

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it worked like charm mudshark thanks for the help
    but since we are programmers would u tell me technically why this happenned ???

  5. #5
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem: you were passing the query string ($sql) to mysql_num_rows() instead of the result of that query.

  6. #6
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, and this wouldn't work either:
    PHP Code:
    echo $num=mysql_num_rows($sql); 
    Define $num first, only then echo $num.


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
  •