As stated in the title, I'm trying to load a single row of user information into an array, preferrably associative. Here's what I have so far:
function load_User_Info($id) {
$parameters = array();
$results = array();
$query = "SELECT * FROM users WHERE User_ID=$id";
$stmt = $this->conn->prepare($query) or die('Error preparing query');
$stmt->execute();
$stmt->store_result();
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field()) {
$parameters[] = &$row[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $parameters);
while ($stmt->fetch()) {
$x=array();
foreach ($row as $key => $val) {
$x[$key] = $val;
}
}
$results[] = $x;
return $results;
}
This is found inside a Mysql class, and here's where it's being used on the page:
Hi, <?php
$mysql = New Mysql();
session_start();
$result = array();
$result = $mysql->load_User_Info($_SESSION['userid']);
echo $result['firstname'] . " " . $result['lastname'];
?>!
Oh the page however, it only displays "Hi, !." I've looked at the mysqli_stmt_fetch page in the PHP manual, and a couple examples were provided from other users and neither of those worked for me either. Thanks in advance.