TimmacJa(k:
You should start a new thread for a new question as it is odd that someone will come in to help.
Here is a suggestion none the less:
<?php
error_reporting(E_ALL);
ini_set("display_errors",1);
mysql_connect("localhost", "", "") or die(mysql_error());
mysql_select_db("mydatabase") or die(mysql_error());
if (empty($_SESSION['username']) {
echo "Not Logged in Or cant Find you in session data";
} else {
$uname = $_SESSION['username'];
$result = mysql_query("SELECT DISTINCT * FROM `mytable` WHERE `username` = '$uname' ";
if (mysql_num_rows($result) > 0) {
$array_data = mysql_fetch_assoc($result);
echo $array_data['surname']."-".$array_data['title'];
} else {
echo "Could Not Find Username $uname";
} // end if num rows
} // end if empty session
?>
You shouldn't use the "LIKE" clause when checking for usernames. If they were logged in and verified, then the username would be identical to the one found in the database otherwise they would not be logged in to begin with.
Also, when attempting to diagnose an issue, put in some error handling. This way you can see exactly what is going on.
You can take out the lines:
error_reporting(E_ALL);
ini_set("display_errors",1);
Once you have figured out what the issue is, that will display ALL errors and notices.
You can also do stuff like:
$result =mysql_query("SELECT * FROM `mytable` WHERE `username` LIKE '$myusername'") or die (mysql_error());