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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:18:56+00:00 2026-06-05T12:18:56+00:00

Okay so I need to push the array that is fetched from a few

  • 0

Okay so I need to push the array that is fetched from a few different tables into a new array. I thought this would do it but it doesn’t. A warning saying array_push() expects parameter 1 to be an array. There is probably something really simple that I have done wrong but Im new to all this PHP stuff so have no idea.
I thought the parameter 1 is an array as an array is fetched from database.

Here’s the code:

$newsfeed = array("apple");

$news = mysql_query("
SELECT * FROM news
UNION ALL
SELECT * FROM feature ORDER BY timestamp DESC LIMIT 1
")or die(mysql_error());

while($row = mysql_fetch_array($news))
{

    $artist = mysql_query("
    SELECT * FROM members WHERE artist='Y'
    ORDER BY timestamp DESC LIMIT 2
    ")or die(mysql_error());

    while($row1 = mysql_fetch_array($artist))
    {
        array_push($newsfeed, $row['title'], $row1['artistname']);
    }
}
echo($newsfeed);
  • 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-05T12:18:57+00:00Added an answer on June 5, 2026 at 12:18 pm

    Look at the documentation for array_push. The first parameter must be the name of the array you’re pushing into.

    array_push($myArray, $row['title'], $row1['artistname']);
    

    $myArray will now have $row['title'] and $row1['artistname'] in it.

    You’re also missing braces on the while loop. You can only omit braces when there is only one line following it. It’s still good practice to have braces anyway.

    If you want to see the value of an array, you should use print_r instead of echo.

    If you want to print out the elements of the array, you’ll need to loop through them. Then you can use echo, when you’re only printing one element of the array. You can’t use it for an entire array or it’ll just print array. See the foreach documentation for examples on how to do this:

    $arr = array("one", "two", "three");
    foreach ($arr as $value) {
        echo $value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I needed an array that could hold different object types and thought I would
Okay, I really need some help with this. I'm new with designing and stuff,
Okay, I have this textfield form that contains some text. What I need to
Okay, I need help. I'm usually pretty good at SQL queries but this one
Okay so this is a bit complex but I need to loop through this
Okay maybe i just need another set of eyes on this, but I have
Okay first to explain the rules: I need a function that constructs a delegate
Okay, so I need something like this: time_span = 1.month date = DateTime.now date
Okay, I need some help here. This is the same old "can't use an
Okay, this is the case: I got a generic base-class which I need to

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.