MySQLi fetch as array

ANSWER: It turns out I had to install mysqlnd

via sudo apt-get install php5-mysqlnd

.

I am using PHP and mysqli. How do I get data from my database as an array? I am currently doing this, but I want it to be like an array:

$stmt = $cxn->prepare('SELECT username, display_name, registered_on, ip_address FROM users WHERE user_id = ?');
$stmt->bind_param('i', $userid);
$stmt->execute();
$stmt->bind_result($username, $display_name, $registered_on, $ip_address);
$stmt->fetch();
$stmt->close();

      

thank

+3


source to share


1 answer


try:



$query = mysqli_query($db, "SELECT `username`, `display_name`, `registered_on`, `ip_address` FROM `users` WHERE `user_id` = '{$user_id}'");
$assoc = mysqli_fetch_assoc($query);

      

0


source







All Articles