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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:00:49+00:00 2026-05-30T02:00:49+00:00

I have a class and inside that class is this function which has a

  • 0

I have a class and inside that class is this function which has a select statement in it

class homeclass {

    function viewHome(){
        $connection = mysql_connect("localhost","will","Idontknow!1");
        if (!$connection){
            die('Could not connect: ' . mysql_error());
        }

        $db = mysql_select_db("willr", $connection);

        $query = "select id, text, image from home";
        $results = mysql_query($query, $connection);
        $results = mysql_fetch_array($results);

        return $results;

        $close = mysql_close($connection);
    }

}

I call that function in another file which is inside a case…like so

case"updatehome":
    $homeArray = $home->viewHome();
    print_r($homeArray);
    break;

When I do a print_r statment I get this back…

Array ( [0] => 1 [id] => 1 [1] => Test Header [text] => Test Header [2] => test.jpg [image] => test.jpg )

My question is why am I getting eveything twice? I dont understand

  • 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-30T02:00:49+00:00Added an answer on May 30, 2026 at 2:00 am

    That’s because you’re using mysql_fetch_array, use mysql_fetch_assoc, which returns only associative array instead, or pass MYSQL_ASSOC as a second argument of mysql_fetch_array

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

Sidebar

Related Questions

I have this code inside a class that is used by an application and
I have a function inside a class that returns a reference to a member
I have a property inside a class that is getting changed by something. The
I have a couple of functions inside a class that essentially do the same
I have a class that I can have many instances of. Inside it creates
Inside of a phase listener class that runs during the RESTORE_VIEW phase, I have
Assume the following: we have class B, which is a private class nested inside
I have a class with an NSDictionary attribute. Inside this class I dispatch another
I have a class (simulation) which creates an instance of another class (GUI). Inside
I have a class API which has full code coverage and uses DI 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.