<?php
// Recupera los mensajes intercambiados entre dos usuarios
$con=mysql_connect("localhost","root","opsivir")
 or die("Error: ".mysql_error());
$name = 'prueba';
$db = mysql_select_db($name,$con)
 or die("Error: ".mysql_error());

$user = mysql_escape_string($_GET["user"]); 
$friend = mysql_escape_string($_GET["friend"]); 
$result = mysql_query("SELECT *FROM mensajes WHERE (nickname = '$user' AND friend = '$friend') OR (nickname = '$friend' AND  friend = '$user')") or die("Error: ".mysql_error());


while($row = mysql_fetch_array($result))
  {
  echo $row['nickname'];
  echo " -> ";
  echo $row['friend'];
  echo  "<br>"; 
  echo $row['comment'];
  echo  "<br>"; 
  echo  "<br>";
  }


mysql_close($con);
?>