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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:06:21+00:00 2026-05-31T14:06:21+00:00

I dont know why but I get this error : Catchable fatal error: Object

  • 0

I dont know why but I get this error
:

Catchable fatal error: Object of class stdClass could not be converted to string

For this code:

$sql = "SELECT * FROM player ORDER BY score DESC LIMIT $begin";
                    $arr = array();
                    while($obj = mysql_fetch_object(mysql_query($sql))) {
                            //$arr[] = $obj;
                            echo $obj;
                    }
  • 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-31T14:06:23+00:00Added an answer on May 31, 2026 at 2:06 pm

    You’re using mysql_fetch_object (which returns an object) and then trying to output it as a string. That won’t work.

    In your case, you should use a function that is capable of printing the contents of the object. There are many but the most straight-forward ones are print_r or var_dump. if you’re outputting in an HTML context, you might wan to wrap a <pre> tag around the output to make it more readable or click “View source” in your browser.

    If you’re writing your own objects, they can also be “converted” to strings by implementing the __toString() magic method

    Also, as people have said in the comments, your code will run the query on each pass through the loop. Check out the documentation here and read the examples.

    Note: You might have simplified the example for SO’s sake, but make sure to sanitize your variables (e.g. $begin) to avoid SQL injections!

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

Sidebar

Related Questions

Heya I get this error message. I've been looking everywhere but I dont know
i dont know but this not working for me im getting garbege value when
i am trying to get some data, but i dont know how can i
I don't know what I'm not doing but I simply cannot get my own
I get a String data from Cursor, but I don't know how to convert
I dont know how doable this is but I'm working on a datatype for
I was solving this problem6 , I dont even know the answer but, when
I know there are more threads about this but they dont help me and
I don't know if the term mass assignment is Rails-specific but I get the
i am using Eclipse 3.7.2. I dont know why but the last line leads

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.