Actually I messed that up... this is simplified
link to out.php?
http://www.gallery.url
<?php
$q = $_SERVER["QUERY_STRING"];
?> // this grabs the variable
<html>
<head>
<title>My Page</title>
</head>
<frameset>
<frame src="myframe.html" />
<frame src="<?php echo('$q'); ?>" /> // loads the url called in the variable
</frameset>
</html>