I spent a long time figuring this out on the internet so I will post this now to hopefully help others with the same problem.
this is to display the currently logged in user using mysql.
this is so they log in with a username, and it displays actual name.

//connect to your database
<?php require_once(mysqlconn.php'); 
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

//rest of your php scripts can go here

$user = $_SESSION['MM_Username'];

mysql_select_db($database_table, $table);
$query_Recordset1 = "SELECT * FROM table WHERE username='$user'";
$Recordset1 = mysql_query($query_Recordset1, $table) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//echo the name
echo $row_Recordset1['name']; ?>

you need a login page which sets the login username to MM_Username
and a restrict access server behaviour otherwise it just wont work.

hope this is helpful to people.

So what exactly is the problem. I see on line 2 you need to add the second quote into the function input but other than that the code looks fine. Could you please explain what the question is as I see a pretty script with a description but no mention on any problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.