How to display data from MySQL database?

The database stores the data about the entered login, and you want to display. The next option:
$userlogin = CS50::query("SELECT username FROM users WHERE id = ?", $_SESSION["id"]);

With the subsequent conclusion:
<h4>Username: <?= $userlogin ?> </h4>
Causes the error:
Notice: Array to string conversion in

CS50::query - function to work with mysql in a cloud environment courses within which and pass this lesson.
July 8th 19 at 16:44
1 answer
July 8th 19 at 16:46
CS50::query gave you back an array that you're trying to get with echo. You need to speak to a specific array key that would bring you are interested in this.

To check what is in the array or using xdebug , or
array (size=1) 0 => array (size=1)'username' => string 'kshnkvn' (length=7). Trying to display the Username: but error not changed. - meda37 commented on July 8th 19 at 16:49
Because element 0 is array 0 => array (size=1)'username' => string 'kshnkvn'. Ie which would bring the userLogin to do so

- Brenden.Gutkows commented on July 8th 19 at 16:52

Find more questions by tags PHPMySQL