HELP PLEASE: want to have a random quote display

catrisit

New Member
Messages
11
Reaction score
0
Points
0
I used to have a script running on my front page that pulled a random quote in from a text file..

for some reason it didn't work on X10's servers

i'd really like to get it running again but need suggestions as to how and what will work on these servers..

help much appreciated, thanks :)

website: http://www.spiritlanguage.org.uk
 

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
It helps tremendously if you could post up the code you are trying to use.
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
This worked for me for a while
PHP:
stop(); quoteTxt.autoSize = "center"; randomQuote = new LoadVars(); randomQuote.onLoad = function() {     quotes = this.quotes.split(";");     quoteTimer = setInterval(newQuote, 10000);     newQuote() }; randomQuote.load("quotes.txt"); function newQuote() {     randomNum = Math.floor(Math.random()*quotes.length);     quoteTxt.text = quotes[randomNum];     quoteTxt._y = ((450-(quoteTxt._height/2))/2); }


---------- Post added at 02:30 PM ---------- Previous post was at 02:29 PM ----------

stop(); quoteTxt.autoSize = "center";
randomQuote = new LoadVars();

randomQuote.onLoad = function() {
quotes = this.quotes.split(";");
quoteTimer = setInterval(newQuote, 10000);
newQuote() };
randomQuote.load("quotes.txt");
function newQuote() { randomNum = Math.floor(Math.random()*quotes.length);
quoteTxt.text = quotes[randomNum];
quoteTxt._y = ((450-(quoteTxt._height/2))/2);
}
 

catrisit

New Member
Messages
11
Reaction score
0
Points
0
thanks vv.

i will try that out and let you know how i get along :)

@cybrax: i don't have any scripting on their just now - i was using a cgi i got from 'Matt's scripts' that called a .txt file...

---------- Post added at 10:33 AM ---------- Previous post was at 09:52 AM ----------

@vv

i tried the php script in my page and modified the .htaccess file [i thought] appropriately :S
now my site is not very happy... http://www.spiritlanguage.org.uk

this is the original cgi i used:

#!/usr/bin/perl -w
use CGI;

my $datafile="randomtext.txt";

my $item_separator="\n\%\n";

my $cgi=new CGI;
print $cgi->header("text/plain");

sub cdie {
print "ERROR: ";
print @_;
exit;
}

open(IDATA, "<", $datafile) or cdie("Data file not readable");
local $/=$item_separator;
my @items=map {s/$item_separator$//;$_} <IDATA>;
close IDATA;
print $cgi->escapeHTML($items[rand @items]);

any thoughts? :)

---------- Post added at 10:34 AM ---------- Previous post was at 10:33 AM ----------

p.s. i have removed the additional .htaccess and cleared the cache but the site is still not working... oops!
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
ahah,
understood your problem..need time to check back.Testing the same anyway again.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
You shouldn't need to set anything in .htaccess to get PHP to work. Make sure you're using a file extension of ".php", not ".html".

Please use
PHP:
, [html] or [code] tags (as appropriate) to separate and format code.

CGI scripts were disabled awhile back due to abuse.

Please don't use [url=http://davespicks.com/essays/notables.html]tables for layout[/url] and presentational HTML (e.g. <font> elements). Stick to [URL="http://webstyleguide.com/wsg3/5-site-structure/2-semantic-markup.html"]semantic HTML[/URL] and CSS.
 
Last edited:

catrisit

New Member
Messages
11
Reaction score
0
Points
0
@misson: thanks i will see how i get on when i try again..

problem with not using tables is my front page is quite reliant on them (see for yourself): http://www.spiritlanguage.org.uk

---------- Post added at 09:08 PM ---------- Previous post was at 09:07 PM ----------

p.s. your 'tables' link is down :)
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
problem with not using tables is my front page is quite reliant on them (see for yourself): http://www.spiritlanguage.org.uk
Not using tables isn't the problem, the reliance on them is, which is why I brought it up.

p.s. your 'tables' link is down :)
Goes to show why cool URIs don't change. The URL for "Why avoiding tables (for layout) is important" has changed only slightly, but it makes a big difference in whether it can be found.
 
Last edited:

catrisit

New Member
Messages
11
Reaction score
0
Points
0
ok @vv.bbcc19, i put the php code in it's own file and called it into my frontpage ( http://wwwspiritlangauge.org.uk ) with:

" include 'http://www.spiritlanguage.org.uk/randomtext.php' "

but it doesn't seem to be working. any ideas? :)
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
It was a tested code..anyways,I will get back to you in a couple of days.
ok @vv.bbcc19, i put the php code in it's own file and called it into my frontpage ( http://wwwspiritlangauge.org.uk ) with:

" include 'http://www.spiritlanguage.org.uk/randomtext.php' "

but it doesn't seem to be working. any ideas? :)


---------- Post added at 10:46 AM ---------- Previous post was at 10:44 AM ----------

Code:
stop();
quoteTxt.autoSize = "center";
randomQuote = new LoadVars();
randomQuote.onLoad = function() {
quotes = this.quotes.split(";");
quoteTimer = setInterval(newQuote, 10000);
newQuote()
};
randomQuote.load("quotes.txt");
function newQuote() {
randomNum = Math.floor(Math.random()*quotes.length);
quoteTxt.text = quotes[randomNum];
quoteTxt._y = ((450-(quoteTxt._height/2))/2);
}
Test this out and pls get back..
 

catrisit

New Member
Messages
11
Reaction score
0
Points
0
thanks vv.bbcc19,

i took my .html file, renamed it a .php and put the php code in where required
although when i put the code into my page it errors with:
"Parse error: syntax error, unexpected '=' in /home/eq3/public_html/indexhmslc.php on line 97"
which is the line "quoteTxt.autoSize = "center";"

when i try putting the php code in a separate .php file and calling via 'include' nothing seems to show up at all....
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
As it turns out, what vv.bbcc19 posted isn't PHP code, though it is marked as such (which shows the importance of using the appropriate tags). It's Javascript.
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
As it turns out, what vv.bbcc19 posted isn't PHP code, though it is marked as such (which shows the importance of using the appropriate tags). It's Javascript.

Ah..yes..sorry its not php but instead of putting
Code:
 I used [php] I think so..I will take care next time.But that code is meant for the same usage but not for php..yeah...thanks mate.
 

catrisit

New Member
Messages
11
Reaction score
0
Points
0
aha! well that helps a bit.. but how do i implement that code on my page?

should it go in the 'head' of my html along with the other javascript? if so how do i call the random text at the bottom of my page? :)
 
Top