It works fine if I use only PHP coding in code#3.
How can I use the "document.write" method in code#3 ?
1) The following code was saved as TESTcall.htm. Program was called by this.
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript" src="http://www.MySite.com/TEST.php"></script>
2) This test text was saved as TEST.txt in the same folder as TEST.php
aaaa
bbbb
cccc
dddd
eeee
ffff
gggg
hhhh
.............................
3) This code was saved as TEST.php
Expand|Select|Wrap|Line Numbers
- <?php
- $quotes = file("http://www.MySite.com/TEST.txt");
- srand((double)microtime() * 1000000);
- $ranNum = rand(0, count($quotes)-1);
- echo 'document.write(\"start<BR>". $quotes[$ranNum]; ."<BR>end\");';
- ?>
All 3 files are in the same folder on my php-available website server.
I have tried all variations of single quotes and double quotes with and
without the backslash inside the "document.write" but cannot get any output!
What am I doing wrong here??