I am trying for ours to get this working and I don't understand what is wrong, I am trying to call a function from the index page that will be returning the name of a user from a table in mysql
. I call a function called getusername()
from index.php
the function is located in func.php that is already included in the index page. When I call a different function located in the func.php is working just fine except this one.
The table in mysql
is called user and has the following attributes userID,Role,Username
The function I called has the following source code
function getusername() {
$query= mysql_query("SELECT * FROM user WHERE UserID=1");
$id = 'UserID';
$role = 'Role';
$username = 'Username';
$rows = mysql_fetch_assoc($query);
echo $username;
}
No matter how many times I tried I cant echo the users name that has id=1 can please anybody help me ?