scusa ma... se hai capito che da
$htmltext2 .= "newWindow.document.open();";
in poi stai scrivendo nella nuova finestra
cosi' come scrivi correttamente un <title> (anche se fuori posto)
$htmltext2 .= "newWindow.document.writeln(\"<title>Profile Gallery Image: \"+ pgimagetitle + \"</title>\");\n";
o correttamente l' immagine
$htmltext2 .= "newWindow.document.writeln(\"<img src= \"+ pgimagefile + \">\");\n";
non ci credo che tu non riesca a seguire la stessa sintassi per scrivere un html sensato, con i tag al posto giusto, stili, etc, come fosse una paginetta html qualsiasi