0

So I'm Getting The Error:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\All Connected\profile.php on line 117

While Try To Check For Friend Request Status Information, I Have Seen People Fix This Using A MySQL Error Dump Or Something Similar But I'm Not Sure, Can I Get Some Help?

This Is A Snippet Of My Code, Only The Parts That Need Fixing

    mysql_connect("illuzionz-pc", "-----", "----------");
    mysql_select_db("allcon");

    $my_id = $_SESSION['user_id'];
    $profile_id = $_GET['id'];

    $check_friend_query = mysql_query("SELECT id FROM friends WHERE (user_one='$my_id' AND user_two='$profile_id') OR (user_one='$profile_id' AND user_two='$my_id')");

    if(mysql_num_rows($check_friend_query) == 1){
      echo "<br><a class='pure-button pure-button-disabled' href='#'>Already Friends!</a><br>";
      echo "<a class='button-error pure-button' href='#'>Unfriend {$user['first_name']}</a>";
    } else {
      mysql_connect("illuzionz-pc", "Admin", "0A562B0CA0");
      mysql_select_db("allcon");

      $my_id = $_SESSION['user_id'];
      $profile_id = $_GET['id'];

      $from_query = mysql_query("SELECT `id` FROM `friend_req` WHERE `from`='$profile_id' AND `to`='$my_id'");
      $to_query = mysql_query("SELECT `id` FROM `friend_req` WHERE `from`='$my_id' AND `to='$profile_id'");

      if(mysql_num_rows($from_query) == 1){
        echo "<a class='button-secondary pure-button' href='#'>Ignore Friend Request</a><br>";
        echo "<a class='button-success pure-button' href='#'>Accept Friend Request</a>";
      } else if(mysql_num_rows($to_query) == 1){
        echo "<a class='button-error pure-button' href='#'>Cancel Friend Request</a>";
      } else {
        echo "<a class='pure-button pure-button-primary' href='#'>Send Friend Request</a>"; 
      }
}
4
  • 2
    Please don't capitalise all the words. It makes it less likely that people will read your question or take it seriously. Commented Nov 27, 2015 at 9:10
  • Sorry @GrahamAsher its a habit.... Commented Nov 27, 2015 at 9:12
  • Also, publishing your connection details (username+password) is probably a bad idea. Commented Nov 27, 2015 at 9:17
  • @Piskvor Thanks just noticed that Commented Nov 27, 2015 at 9:27

1 Answer 1

3

Your mysql_query has returned false as you passed it invalid SQL. Fix your $to_query to:

$to_query = mysql_query("SELECT `id` FROM `friend_req` WHERE `from`='$my_id' AND `to`='$profile_id'");
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks That Fixed My Problem @WilliamMadede I'll Select You As The Answer That Worked When I Can (I Have To Wait 8 Mins)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.