Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I tried to print a record in MySQL, but got an error. I have this method:
$aa = DB::select("select user from statystyki where id = '10'"); print $aa->user;
The function mysql_fetch_array is not working.
mysql_fetch_array
DB::select returns an array of objects. If you var_dump($aa), you can see the structure, which should look like this:
DB::select
var_dump($aa)
array( 0 => object(stdClass)( 'user' => 'username' ) )
You want to print the user this way:
$aa[0]->user;
Add a comment
Make one loop. Try this way
$aa = DB::select("select user from statystyki where id = '10'"); foreach($aa as $user) { print $user->user; }
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.