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 6749793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:43:56+00:00 2026-05-26T12:43:56+00:00

The following function is set up to: Collect the user_id from my database, as

  • 0

The following function is set up to:

  1. Collect the user_id from my database, as you can see below WHERE subscriber = '$user'. And then:
  2. return the possible multiple values that user_id are.

However, when I’ve tried to use this function, it has only collected an array, with the key 0, and value user_id. For apparent reasons I want the array to contain the numerical value that is in the user_id column in my database with the key user_id.

function get_subscribitions($user)
{
    $user = mysql_real_escape_string ($user);

    $sql = "SELECT 'user_id' FROM `subscribe` WHERE subscriber = '$user'";

    $result = mysql_query($sql);

    $rows = array();

    while ($row = mysql_fetch_assoc($result)) {
        $rows[] = $row;
    }

    mysql_free_result($result);

    return $rows;
}

Can anyone please pinpoint where I’m making the error leading to these related problems?

Any help appreciated, thank you in advance!

  • 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-26T12:43:57+00:00Added an answer on May 26, 2026 at 12:43 pm

    It should be:

     function get_subscribitions($user)
    {
    
    $user = mysql_real_escape_string ($user);
    
      $sql = "SELECT user_id FROM `subscribe` WHERE subscriber = '$user'";
    
     $result = mysql_query($sql);
    
      $rows = array();
    
      while ($row = mysql_fetch_assoc($result)) {
          $rows[] = $row['user_id'];
      }
    
      mysql_free_result($result);
    
      return $rows;
    }
    

    There were unnecessary quotes in the query and you were not reading the $row array properly

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take the following function: DataTable go() { return someTableAdapter.getSomeData(); } When I set a
I have the following function that is pulling data from a database. The ajax
I'm using the following function to insert data into a MySQL database. Can someone
I'm using the following function, called from document.ready(), to set a fadeIn/fadeOut effect on
I'm using the following function that changes a calendar selection at a set time
In the following code I get a segmentation fault: Set *getpar() {...} char function(...)
Good Morning, I have got the following function: FUNCTION queryDatabaseCount(sqlStr) SET queryDatabaseCountRecordSet = databaseConnection.Execute(sqlStr)
I have the following function which limits the amount of characters you can enter
I use following function to convert datetimes from UTC to my local time (West
Given the following function: create or replace FUNCTION GETADDRESSES RETURN sys_refcursor IS address_cursor sys_refcursor;

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.