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!