Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6652851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:11:33+00:00 2026-05-26T01:11:33+00:00

I am not sure why, But when I run the following code and there

  • 0

I am not sure why, But when I run the following code and there is nothing in the database I get the error [false] when I view the PHP page instead of the correct error message

public function fetchfriends($userid)
{
    $this->userid = $userid;
    $contact_check = mysql_query("
              SELECT *
              FROM user_contact
              WHERE from_userid = '{$this->userid}'
              AND approved   != 1
            ");


if(!mysql_num_rows($contact_check))
        {

                $arr = array("error" => "No Friends?<br/>Search above for New users or invite some friends.");
                print json_encode($arr);
        }
        else
        {
                $friendlook = mysql_query("
                    SELECT friend.to_userid,
                           info.username,
                           info.firstname,
                           info.lastname,
                           info.status,
                           astatus.onlinestatus

                    FROM      user_contact AS friend
                    LEFT JOIN user_info    AS info    ON friend.to_userid = info.id
                    LEFT JOIN user_online  AS astatus ON friend.to_userid = astatus.userid

                    WHERE friend.from_userid = '{$this->userid}'
                      AND friend.approved    = 1
                      AND friend.to_userid   = info.id

                    ORDER BY astatus.onlinestatus DESC
                ");

                $row = mysql_fetch_assoc($friendlook);
                $rows[] = $row;
                print json_encode($rows);
        }
    }

I was wondering if anyone would know why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:11:34+00:00Added an answer on May 26, 2026 at 1:11 am

    You have 2 SQL queries and you only check if the first has any results. The problem is that if the first has results and the second doesn’t you will not get your error message, but the [false] you receive now.

    Your code should look something like:

    public function fetchfriends($userid)
    {
        $this->userid = $userid;
        $contact_check = mysql_query("SELECT * FROM user_contact WHERE from_userid = '{$this->userid}' AND approved != 1");
    
        if(mysql_num_rows($contact_check))
        {
            $friendlook = mysql_query("SELECT friend.to_userid, info.username, info.firstname, info.lastname, info.status, astatus.onlinestatus FROM user_contact as friend LEFT JOIN user_info as info ON friend.to_userid = info.id LEFT JOIN user_online as astatus ON friend.to_userid = astatus.userid WHERE friend.to_userid = info.id AND friend.from_userid = '{$this->userid}' AND friend.approved = 1 ORDER BY astatus.onlinestatus DESC");
    
            if (mysql_num_rows($friendlook)) {
                $row = mysql_fetch_assoc($friendlook);
                $rows[] = $row;
                print json_encode($rows);
            } else {
                $arr = array("error" => "Your friends are not online");
                print json_encode($arr);
            }
    
            return;
        }
    
        $arr = array("error" => "No Friends?<br/>Search above for New users or invite some friends.");
        print json_encode($arr);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure what the appropriate terminology is, but in trying to run simulations,
I am thinking on the following approach but not sure if its the best
I want to do the following with regular expressions but not sure how to
I have the following code with the following errors and I am not sure
I am using D-Day calendar and I am not sure but I got a
I know what i want but not sure of the name and required tools
I'm starting out with MVC but not sure it's the best option. I need
I am fairly new to MVC but not sure exactly which Redirect... replaces the
I found this in Ryan Bates' railscast site, but not sure how it works.
I'm trying to extract about 72000 SInt32s from the iPhone, but not sure what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.