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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:04:22+00:00 2026-05-22T22:04:22+00:00

I am trying to delete every follower from an array using PHP. However I

  • 0

I am trying to delete every follower from an array using PHP. However I am receiving the error :

Warning: Invalid argument supplied for foreach() in /home/nucleusi/public_html/maxkdevelopment.co.uk/SocialPic/socialPic.php

Please can you tell me where I am going wrong?

$arg = mysql_query("SELECT `followerUserID` FROM Following 
   WHERE `followingUserID` = '$id'") or die("1. " . mysql_error());
$array = mysql_fetch_array($arg);
foreach($array['followerUserID'] as $accID) {
  mysql_query("UPDATE Accounts SET `Following Count` = (`Following Count`-1) 
    WHERE `id` = '$accID'") or die("2. " . mysql_error());
}
$arg = mysql_query("SELECT `followingUserID` FROM Following 
  WHERE `followerUserID` = '$id'") or die("3. " . mysql_error());
$array = mysql_fetch_array($arg);
foreach($array['followingUserID'] as $accID) {
  mysql_query("UPDATE Accounts SET `Followed Count` = (`Followed Count`-1) 
    WHERE `id` = '$accID'") or die("4. " . mysql_error());
}
  • 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-22T22:04:24+00:00Added an answer on May 22, 2026 at 10:04 pm

    MySQL will not return arrays in a field, indexing an array retrieved from a query will return a single field, and foreach() expects an array. What you have written cannot work. Use a while() loop to iterate through the query results as one would normally do.

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

Sidebar

Related Questions

I'm trying to delete all digits from a string. However the next code deletes
I am trying to delete every character from the beginning of my string, that
I am trying to delete several rows from a MySQL 5.0.45 database: delete from
I'm trying to delete a directory that contains XML files from a remote computer.
I am trying to delete an old user from our perforce installation. A previous
i am trying to delete some files using a batch file.. (winxp) my problem
I'm trying to get a simple delete every pointer in my vector/list/... function written
I'm trying to write a function that will delete every row in a given
Here is what im trying to do explained in a query DELETE FROM table
I'm actually trying to delete every space in a small function statement excepted if

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.