$query = mysql_query("SELECT a.id, a.username, b.password FROM table1 a, table2 b ON a.id=b.id LIMIT 1");
$row = mysql_fetch_array($query);
$id = $row['id'];
$uname = $row['username'];
$pwd = $row['password'];
You need to declare that you want to select an ID, username and password to be returned. Using ON just defines what you are defining as the criteria for the match. MySQL will not return those fields by default.