I feel like such a noob for asking another question, but I cba to google for hours to see if I can find a fix anywhere. Since no one has 100% the same code, I'm just gonna go ahead and ask another question since thats what this community is here for :P
So yeah, what I did is the following; I made a member_list where all the usernames are listed and linked to their own page. Now I want to create that own page by getting their information from the database. The links are as following: profile.php?username=USERNAMEOFTHEUSER, example: domain.com/profile.php?username=robert
I made a new function called 'fetch_user_info' and stored it in 'user_info.php'. This is the code of the file:
$users = array();
$result = mysqli_query($mysqli,"SELECT username FROM members");
while($row = mysqli_fetch_assoc($result)){
$users[] = $row['username'];
}
function fetch_user_info($username){
$mysqli = "SELECT username, name, age, FROM members WHERE username = '$username'";
$result = mysqli_query($mysqli);
return mysqli_fetch_assoc($result);
}
What I'm troublin' with is getting his (or anyone elses) data from the database. I know I must be using the $_GET. This is my testdocuments code;
<?php
include '../../includes/db/db_connect.php';
include '../../includes/fct/functions.php';
include 'user_info.php';
sec_session_start();
$user_info = fetch_user_info($_GET['username']);
print_r($user_info);
?>
<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
I'm getting the following errors:
Warning: mysqli_query() expects at least 2 parameters, 1 given in Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in
What I want is to echo their username, name, age etc. out anywhere I want. So it must be a variable!
Any help would be appreciated!