I am creating a user "friend system" from a tutorial on Youtube. Everything is working fine except the "members" page. I want it to display all the site's members by their username. I have been over this part of the tutorial several times, and am pretty sure that i have not made an error. But, when I test the page out, it lists all the members, but does not display the username. I get this error
"Notice: Undefined index: $field in J:\TestSite\socialnetworkcode\functions.php on line 16"
I know that the variable "$field" is undefined in the functions page, the strange part is that his (the person who created the tutorial) page works fine and diplays the usernames. I do not know what to define it as, or why his works without defining "$field" and mine doesn't.
<?php
session_start();
function loggedin(){
if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])){
return true;
} else {
return false;
}
}
function getuser($id, $field){
$query = mysql_query("SELECT $field FROM users WHERE id='$id'");
$run = mysql_fetch_array($query);
return $run['$field'];
}
?>