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

  • Home
  • SEARCH
  • 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 7728355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:41:48+00:00 2026-06-01T05:41:48+00:00

I have a table contacts that has a field arrayOfMembers (JSON format) and a

  • 0

I have a table contacts that has a field arrayOfMembers (JSON format) and a table users with field userId (int).

$recipientId=getUserIdForEmail($recipientEmail);
addUserIdToContactsMemberIds($noteId, $recipientId);

function addUserIdToContactsMemberIds($noteId, $userId)
     {
          $memberData=mysql_query("SELECT * FROM contacts WHERE contactId='$contactId'");
          $memberResultData = mysql_fetch_assoc($memberData);
          $arrayOfMemberIds=json_decode($memberResultData['arrayOfMembers']);
          $arrayOfMemberIds[]=$userId;
          $sendback=json_encode($arrayOfMemberIds);
          mysql_query("UPDATE notes SET arrayOfMembers='$sendback' where contactId='$contactId'");
     }

function getUserIdForEmail($email)
    {
         $data=mysql_query("SELECT userId FROM users WHERE userEmail='$email'");
         $result = mysql_fetch_assoc($data);
         return $result["userId"];
    }

However, the $userId is being stored as a string with quotations, so that where if I originally have [1], after adding a new userId, it looks like this [1,”2″] even though it should look like [1,2].

If I manually enter an int value in the line: $arrayOfMemberIds[]=$userId; and put $arrayOfMemberIds[]=5, then I get the correct result, that is [1,5]. Why is this happening?

  • 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-06-01T05:41:49+00:00Added an answer on June 1, 2026 at 5:41 am

    If you have an issue with the ID being a string (in most cases, it isn’t a big deal), then simply use intval():

    $arrayOfMemberIds[] = intval($userId);
    

    or

    return intval($result["userId"]);
    

    Why’s it a string?

    mysql_fetch_assoc returns all values as a string, regardless of the type in the database. Straight from PHP documentation:

    Returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows. – http://php.net/mysql_fetch_assoc

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

Sidebar

Related Questions

I have a table, contacts, that has a dozen columns or so. I want
I have 3 tables: subcontracts, companies and contacts. Each table has a active_status flags
I have a table in a my Dynamic Data website that has a Primary
I have a table that has columns in a template: <div id=petDiv> <table> <thead>
I have a portal in my contacts table layout that shows related mention in
I have table named as contacts which has nearly 1.2 million records we use
So i have a mysql query that queries a table contacts each contact then
I have a table of contacts and a table of postcode data. I need
I have a contacts table which contains fields such as postcode , first name
Here's my case: I have a table view showing contacts. Add button in the

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.