I am using a script which allows user to submit a url for their site. The url is saved in a MySQL database with other things like site name and description.

The url is saved in a variable: $url. Now I have the urls and sites listed in a page and I want them to open up in a new window when they are clicked.

Here is some of the code:

function list_sites($mode='top', $category_id='') {
global $directory_tablename, $root_category_id, $PHP_SELF, $num_top_sites, $num_new_sites;
if(!$link_id) $link_id = db_connect($default_dbname);
if($mode=='top') {
$order_by_str = 'ORDER BY hit DESC';
$limit_str = "LIMIT $num_top_sites";
else {
$order_by_str = 'ORDER BY registerdate DESC';
$limit_str = "LIMIT $num_new_sites";
if($category_id == $root_category_id) $category_str = '1';
else $category_str = "category_id LIKE '$category_id%'";
$query = "SELECT url_id, title, url FROM $directory_tablename WHERE $category_str AND approved = 1 $order_by_str $limit_str";
$result = mysql_query($query);
if(!$result) echo sql_error();
if(mysql_num_rows($result) > 0) {
if($mode=='top') echo "Top $num_top_sites Sites<BR>";
else if($mode=='new') echo "New $num_new_sites Sites<BR>";
$i = 1;
while($query_data = mysql_fetch_array($result)) {
$url_id = $query_data["url_id"];
$url = "http://" . $query_data["url"];
$title = $query_data["title"];
echo " <A HREF=\"$PHP_SELF?action=go_url&url=$url&url_id=$url_id\">$i. $title</A><BR>\n";

This displays the sites. Now when they are clicked on $action = go_url which executes the go_url function:

function go_url() {
global $default_dbname, $directory_tablename;
global $url_id, $url;
if(isset($url_id) && isset($url)) {
if(!$link_id) $link_id = db_connect($default_dbname);
$result = mysql_query("UPDATE $directory_tablename SET hit = hit + 1 WHERE url_id=$url_id");
if(!$result) error_message(sql_error());
rock("Location: $url");

Now the function rock should open it up in a new window but it doesnt.

function rock() {
global $new_window_width, $new_window_height;
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function open_window(url) {
var NEW_WIN = null;

NEW_WIN = window.open ("","RecordViewer","toolbar=no,width="+<?php echo $new_window_width ?>+",height="+<?php echo $new_window_height ?>+",directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
NEW_WIN.location.href = url;

What is wrong here?
Thanks for your help,