Ho fatto svariate prove tra cui anche quella di mettere assurdamente il codice così, ma non funziona:
Codice PHP:
<?php     
if(!isset($_SESSION)){session_start();}       
if(!isset(
$_SESSION['utente'])){       
    
header("location: login2.php?azione=login");      
    exit();        
}  
?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>pagina</title>  
</head>  
<body style="background-color:#036; width: 100%; height: 100%; display: block">  
<div id="barra" style="height: 8%; position: fixed; top: 0px; bottom: 0; left: 0; width: 100%; background-color: #006699; border-bottom: 1px solid #133783; position:fixed !important">   
<p style="margin-top:1%; margin-bottom:1%; margin-left:1%; color:#FFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:150%; font-weight:bold; text-align:left">KnowEveryone [url="profile2.php"]<?php $utenteucwords($_SESSION['utente']); print "($utente)";?>[/url][url="login2.php?azione=logout"]Esci[/url]</p>  
</div>   
<?php   
include 'header.php';    
print 
"<p class='saluto'>$utente</p>";   
?>  
</div>  
<div class="sidebar2">   
<iframe name="visualizza" width="70%" height="80%" frameborder="1" src="bacheca_visualizza6.php" style="background-color:white; border:1px solid white" scrolling="yes"></iframe>  
<iframe name="visualizza3" width="29%" height="80%" src="chat/chatpiccola.php"></iframe>  
<center><iframe name="visualizza2" width="100%" height="8%" frameborder="1" src="bacheca_input.php" style="background-color:white; border:1px solid #CCCCCC; background-color:#0165B6" scrolling="no"></iframe></center>   
</div>   
<table border=0 width=100% cellpadding=0 cellspacing=0>  
<div class="sidebar1">   
<center>   
<?php   
error_reporting
(E_ALL);   
$dati mysql_query("SELECT foto FROM utenti WHERE username='".$_SESSION['utente']."'");   
$risultatomysql_fetch_array($dati);   
$_SESSION['foto'] = $risultato['foto'];   
echo <<<
EOF  
[url="java-script:Popup('modifica_foto.php')"][img]uploads/{$risultato['foto']}[/img][/url]  
EOF;  
?>   
<iframe name="visualizza" width="65%" height="20%" frameborder="1" src="infopersonali.php" style="margin-top:10%; background-color:white; border:1px solid black"></iframe>   
<p style="margin-top:5%">[url="modifica_dati2.php"][modifica dati][/url]</p>   
<iframe name="visualizza" width="65%" max-height="25%" frameborder="1" src="statoprofilo.php" style="background-color:white; border:1px solid black"></iframe>   
</div>  
</div>  
</body>    
</html>
<?php 
include('chat/chat.php'); 
session_start(); 
?> 
<html> 
<head> 
<script type="text/javascript" src="js/jquery.js"></script> 
<script type="text/javascript" src="js/chat.js"></script> 
<link type="text/css" rel="stylesheet" media="all" href="css/chat.css" />  
<link type="text/css" rel="stylesheet" media="all" href="css/screen.css" />  
<link type="text/css" rel="stylesheet" media="all" href="css/screen_ie.css" />  
</head> 
<body> 
<?php 
// salvo nella sessione l'username dell'utente 
$_SESSION['username'] = $_SESSION['utente']; 

$res mysql_query("SELECT username FROM utenti WHERE stato = 1 AND username != '".$_SESSION['utente']."'"); 

while (
$row mysql_fetch_array($res)){ 
  
// creo dinamicamente il link per aprire la chat 
  
echo "<a href=\"java-script:void(0)\" onclick=\"java-script:chatWith('" $row['username'] . "')\">Chatta con " $row['username'] . "</a>"

?> 
</body> 
</html>
Spero di poter avere un vostro aiuto al più presto: sto impazzendo