SYP}{ER
11-24-2002, 12:12 AM
I have a file stored on rbnb.aaron-wright.com which generates itself as a .js file. The JS file has this in it:
document.write ('Random fact here.');
That fact is generated using a random mysql_query and there are no errors in my document. Now I use this to have something document.written onto my site at aaron-wright.com:
<script type="text/javascript" src="http://rbnb.aaron-wright.com/rand.php?params=gohere"></script>
The thing is, it doesn't work. Nothing is written.
That same file is stored on my home computer running PHPDev and if I point to that file instead, it works!
What's going on?
Here's the source:
<?
header("Content-type: text/javascript");
mysql_connect ("****","****","****");
mysql_select_db ("****");
if ($section!="avatars"){
$sql = "SELECT body,source FROM entries WHERE LENGTH(body)<".$maxlength." AND section='$section' ORDER BY RAND() LIMIT 1";
$random_row = mysql_fetch_array (mysql_query ($sql));
$random_row["body"] = str_replace("'","\'",$random_row["body"]);
$random_row["source"] = str_replace("'","\'",$random_row["source"]);
if ($type=="oneliner"){
?>
document.write ('<?=$random_row["body"]?> — <'+'i><?=$random_row["source"]?></'+'i>');
<?
}else if ($type=="formatted"){
?>
document.write ('<?=$random_row["body"]?><br /><br /><div align="right"> — <i><?=$random_row["source"]?></i></div>');
<?
}
}
?>
Thanks for any ideas :)
document.write ('Random fact here.');
That fact is generated using a random mysql_query and there are no errors in my document. Now I use this to have something document.written onto my site at aaron-wright.com:
<script type="text/javascript" src="http://rbnb.aaron-wright.com/rand.php?params=gohere"></script>
The thing is, it doesn't work. Nothing is written.
That same file is stored on my home computer running PHPDev and if I point to that file instead, it works!
What's going on?
Here's the source:
<?
header("Content-type: text/javascript");
mysql_connect ("****","****","****");
mysql_select_db ("****");
if ($section!="avatars"){
$sql = "SELECT body,source FROM entries WHERE LENGTH(body)<".$maxlength." AND section='$section' ORDER BY RAND() LIMIT 1";
$random_row = mysql_fetch_array (mysql_query ($sql));
$random_row["body"] = str_replace("'","\'",$random_row["body"]);
$random_row["source"] = str_replace("'","\'",$random_row["source"]);
if ($type=="oneliner"){
?>
document.write ('<?=$random_row["body"]?> — <'+'i><?=$random_row["source"]?></'+'i>');
<?
}else if ($type=="formatted"){
?>
document.write ('<?=$random_row["body"]?><br /><br /><div align="right"> — <i><?=$random_row["source"]?></i></div>');
<?
}
}
?>
Thanks for any ideas :)