I have a block of JavaScript code that is designed to be embedded into any web page. It displays a list of items from a database. In the .js file is actually a lot of PHP code within JavaScript.

The problem: The cut-n-paste widget does not actually show up. It's just blank. There is no error data in Apache or PHP, so I am stumped. This is happening on all 3 of my servers and in both IE and Firefox.

Example: Website Blog Proxy List Widget

Half way down the page it says 'The widget looks like this:', but as you can see no widget is actually displayed there where it's supossed to be.

This is the JavaScript code designed to be embedded:

<p><script type="text/javascript" src="http://www.vectrotest.co.cc/list.js"></script></p>
This is what's actually inside of list.js (there is JavaScript mixed with PHP):

document.write('<style type="text/css">option {padding:1px 3px; }</style>');


$db = new Database();
if (!$db->connect($db_host, $db_user, $db_pass, $db_name))

$sql = "SELECT id, proxy, hits, time
                FROM {$db_tp}proxy
                ORDER BY time DESC
                LIMIT 0, 50";
$res = $db->query($sql);
document.write('<form method="get" name="form" action="http://www.<?php echo $cfg['domain'] ?>/redirect.php" target="_blank" style="border:1px solid #ccc;padding:3px 0;font-size:10px;width:190px;text-align:center;">');
document.write('<b title="All Links Open In New Window/Tab">50 Newest Proxies</b><br />');
document.write('<select name="id" size="12" style="width:180px;border:1px solid #ccc;margin:3px 0;" onclick="document.form.submit();">');
while ($row = $db->fetch_assoc($res)){ ?>
document.write('<option value="<?php echo $row['id'] ?>"><?php echo rtrim(str_replace(array('http://','https://','www.'),'',$row['proxy']),'/') ?></option>');
<?php } ?>
document.write('</select><br /><a href="http://www.<?php echo $cfg['domain'] ?>/" title="Get A Free List Widget For Your Website or Blog!" target="_blank" style="color: black; text-decoration: none">Powered by <?php echo $cfg['domain'] ?></a></form>');
I'm not sure if this is a server problem, a browser problem a JavaScript problem or a PHP problem.