Little php script that show a Random Quote in a phpbox / block.
- DEMO (http://www.tnquad.us/cripdemo.php)
I placed a readme file in the .zip to assit you, but just ask for any help..TIP* the main thing is to have correct paths.
Add all your own Random Quotes.
Enjoy, crip! ;D
Download here.
Funny stuff. I might install. Looks as easy as uploading 3 files and calling some PHP in a side block.
Thanks for sharing.
I can never get that command to work include "./quote/randomquote.php";
ok my quote folder is rranderson\arcade\quote or http://www.rranderson.com/arcade/quote
would that path work because I keep getting a
$number-1){ // If ran out of quotes, start again! $num=0; } if (file_exists($directory.$quotecountfile)) { $nu = fopen ($directory.$quotecountfile, "w"); fputs($nu,$num); } else { die("Cant Find $quotecountfile"); } } // display the quote on the page echo "$quotes[$num]"; ?>error
in randomquote.pnp i have $directory = "./quote/";
in the PHP block I have include "./quote/randomquote.php";
What am I doing wrong - time for me to learn this
Thanks
try the path without the "."
include "/quote/randomquote.php";
After you upload your "quote" folder in your forum root, just go to a phpbox and add what Incbin put..
this:
****************************
include "/quote/randomquote.php";
****************************
nothing more, nothing less.
It's EZ now guys, once Bloc and crew told me how to add it..Lol..
Later, crip~ ;D
Quote from: IchBinâââ,¬Å¾Ã,¢ on February 08, 2006, 07:40:17 PM
try the path without the "."
include "/quote/randomquote.php";
Get the same error errr I know it can not be this hard
Did you try this?
include "/rranderson/arcade/quote/randomquote.php";
I just checked my phpbox .. this is all thats in it.
include "./quote/randomquote.php";
Ray, be sure you have the path from your randomquote.php correct .. the "quotes" folder Must be in the root of your Forum / Arcade / Where ever, Or the call for Randomquote.php will send errors until your get the path right..
I have my "quote" Folder inside of my "Forum" Folder where / Smileys / Themes / Packages / Sources / et-ceteras..are.
Later, Crip~ ;D
Try using:
include "quote/randomquote.php";
see if that works.
or perhaps try
require("quote/randomquote.php");
with and without the leading slash before the word "quote".
Quote from: IchBinâââ,¬Å¾Ã,¢ on February 09, 2006, 02:07:10 AM
Did you try this?
include "/rranderson/arcade/quote/randomquote.php";
no work
Quote from: Rasyr on February 09, 2006, 01:52:32 PM
Try using:
include "quote/randomquote.php";
see if that works.
or perhaps try
require("quote/randomquote.php");
with and without the leading slash before the word "quote".
NO no work here also -- will look at ir more later
Ray,
in the file randomquote.php make sure you have a path set similar to this:
$random = true;
$directory = "/home/www/public_html/forum/quote/";
$quotefile = "randomquote.inc";
$quotecountfile = "displayquote.inc";
Leave
- $quotefile
and
- $quotecountfile
as it looks here, and it should work.
crip~
Quote from: cripâ€Ã,¦ on February 09, 2006, 09:14:19 PM
Ray,
in the file randomquote.php make sure you have a path set similar to this:
$random = true;
$directory = "/home/www/public_html/forum/quote/";
$quotefile = "randomquote.inc";
$quotecountfile = "displayquote.inc";
Leave - $quotefile
and
- $quotecountfile
as it looks here, and it should work.
crip~
Tried this
$random = true;
$directory = "/rranderson/arcade/quote/"; //Put the correct path//
$quotefile = "randomquote.inc"; //Add all quotes in this file in one line//
$quotecountfile = "displayquote.inc"; //This counts quotes, could be optionable if random is set false//No work -- I always get that same error -- all files are located in the quote folder
Path from your www / or public_html..
Last try:
$directory = "/home/rranderson/public_html/arcade/quote/";
Hope you get it working RayR.
crip
Quote from: cripâ€Ã,¦ on February 09, 2006, 11:12:35 PM
Path from your www / or public_html..
Last try:
$directory = "/home/rranderson/public_html/arcade/quote/";
Hope you get it working RayR.
crip
Im not on a linux computer I use windows with IIs so that may be the problem.. the paths are different. For me it is d:\rranderson\arcade\quote -- umm maybe I will try that path
Your right Ray.......
now ya tell me.. ;D
For me it is d:\rranderson\arcade\quote -- umm maybe I will try that path
Still no work -- I have never got the command include to work
Quote from: Ray on February 10, 2006, 05:38:34 PM
For me it is d:\rranderson\arcade\quote -- umm maybe I will try that path
Still no work -- I have never got the command include to work
to add one \ at the end Ray ...
Fel
tried that also - here is the error
$number-1){ // If ran out of quotes, start again! $num=0; } if (file_exists($directory.$quotecountfile)) { $nu = fopen ($directory.$quotecountfile, "w"); fputs($nu,$num); } else { die("Cant Find $quotecountfile"); } } // display the quote on the page echo "$quotes[$num]"; ?>
I played with this a long time and I know nothing about code but was getting the same error that ray has here, basically showing the code from randomquote.php instead of a quote. I got it to work by doing this:
$directory = "./quote/"; //Put the correct path//
and this
include "./quote/randomquote.php";
why that works I have no idea :laugh:
maybe something to do with server setting?
great little mod, I love it 8)
thanks alot
I just remembered I also did this:
I put "php" after <? at the beginning of randomquote.php
so the config part looks like this:
<?php
/* Config Part --------------------------------------------------------------------------------------------------------------*/
$random = true;
$directory = "./quote/"; //Put the correct path//
$quotefile = "randomquote.inc"; //Add all quotes in this file in one line//
$quotecountfile = "displayquote.inc"; //This counts quotes, could be optionable if random is set false//
/* End of Config Part -------------------------------------------------------------------------------------------------------*/
and now I notice that when I take out the "php" it doesn't work anymore so that might be the only change that needs to be made, so try that first.
good luck
:)
Sure,
anything that "(works)" .. suppose it's a bit different on different servers..
Quote from: L1 on February 16, 2006, 08:15:31 AM
I played with this a long time and I know nothing about code but was getting the same error that ray has here, basically showing the code from randomquote.php instead of a quote. I got it to work by doing this:
$directory = "./quote/"; //Put the correct path//
and this
include "./quote/randomquote.php";
why that works I have no idea :laugh:
maybe something to do with server setting?
great little mod, I love it 8)
thanks alot
That fixed it for me and also the adding the php.
Now to figure how to make it center when displayed? -- thanks all for the tips
OK now that it is working -- How to center the qoute text in a block??
<p align="center"><? php quotes ?></p>
or
<center>
<? php quotes
?>
</center>
Quote from: ÂÃ,»cripÂÃ,« on February 22, 2006, 12:20:04 AM
<p align="center"><? php quotes ?></p>
or
<center>
<? php quotes
?>
</center>
I fixed it and had to do it in the randomquote.php file
and all the trouble I had and it was just becaue the php after the <? was not their
Man learns something new everyday .. ya know Rayzer.. ;)
Soo I tried to install this and will try again.
I think the reason I couldnt get it to work was cause I started on page one with all the helpful editing where as I should have looked back to see where the actual solution was. :)
need any help?
Eh not right now I have to get back to school and stuff.
So if you want to pm me directions that would be cool.
Directions in .zip & on first post on this thread.
Did you just do that or have they been there?
I always feel so dumb around you guys. ^_-
I put it there when I 1st posted it. :)
-_-
Ok so I uploaded all three files to the copy and pasted name quote in my forums root folder.
Looks like /public_html/forums/quote
So I updated my include statement in the php block to:
include "./forums/quote/randomquote.php";
I also tried it without the .
Any I dea of what I am doing wrong?
----------------------------------------------------------------------
My Current Code (randomquote.php)
<?
/* Config Part --------------------------------------------------------------------------------------------------------------*/
$random = true;
$directory = "home/www/public_html/quote/"; //Put the correct path//
$quotefile = "randomquote.inc"; //Add all quotes in this file in one line//
$quotecountfile = "displayquote.inc"; //This counts quotes, could be optionable if random is set false//
/* End of Config Part -------------------------------------------------------------------------------------------------------*/
$quotes = file($directory.$quotefile);
$number = count($quotes);
if($random){
$num = rand(0,$number-1);
}
else{
$num = file($directory.$quotecountfile);
$num = $num[0]+1;
if($num>$number-1){ // If ran out of quotes, start again!
$num=0;
}
if (file_exists($directory.$quotecountfile)) {
$nu = fopen ($directory.$quotecountfile, "w");
fputs($nu,$num);
}
else {
die("Cant Find $quotecountfile");
}
}
// display the quote on the page
echo "$quotes[$num]";
?>
----------------------------------------------------------------------
Quote
README:
Upload all 3 files into a directory preferably named 'quote' into the root of your forum.....
URL: www.yoursite.com/quote/randomquote.php //You'll figure it out the right path//
-------------------------------------------------------------------------------------------------------------
randomquote.php //Fix the paths in this file//
-------------------
displayquote.inc //Counts your quotes, could be optionable//
------------------
randomquote.inc //Put all quotes in one line in this file//
---------------------------------------------------------------------------------------------------------------
//Put this in a phpbox/block//
//*--------------------------------------//*
include "./quote/randomquote.php";
//*--------------------------------------//*
//At each reload / refresh you get a new Random quote//
//The more quotes you have, the more Random they become//
///////enjoy, crip~/////////
[/qoute]
Change
<?
/* Config Part --------------------------------------------------------------------------------------------------------------*/
$random = true;
$directory = "home/www/public_html/quote/"; //Put the correct path//
$quotefile = "randomquote.inc"; //Add all quotes in this file in one line//
$quotecountfile = "displayquote.inc"; //This counts quotes, could be optionable if random is set false//
/* End of Config Part -------------------------------------------------------------------------------------------------------*/
to
<?php
/* Config Part --------------------------------------------------------------------------------------------------------------*/
$random = true;
$directory = "home/www/public_html/quote/"; //Put the correct path//
$quotefile = "randomquote.inc"; //Add all quotes in this file in one line//
$quotecountfile = "displayquote.inc"; //This counts quotes, could be optionable if random is set false//
/* End of Config Part -------------------------------------------------------------------------------------------------------*/
This is correct...
Quote
My Current Code (randomquote.php)
<?
/* Config Part --------------------------------------------------------------------------------------------------------------*/
$random = true;
$directory = "home/www/public_html/quote/"; //Put the correct path//
$quotefile = "randomquote.inc"; //Add all quotes in this file in one line//
$quotecountfile = "displayquote.inc"; //This counts quotes, could be optionable if random is set false//
/* End of Config Part -------------------------------------------------------------------------------------------------------*/
$quotes = file($directory.$quotefile);
$number = count($quotes);
if($random){
$num = rand(0,$number-1);
}
else{
$num = file($directory.$quotecountfile);
$num = $num[0]+1;
if($num>$number-1){ // If ran out of quotes, start again!
$num=0;
}
if (file_exists($directory.$quotecountfile)) {
$nu = fopen ($directory.$quotecountfile, "w");
fputs($nu,$num);
}
else {
die("Cant Find $quotecountfile");
}
}
// display the quote on the page
echo "$quotes[$num]";
?>
Still not got it?
Nope still not working just getting a blank spot on my forums. Is this supposed to be in the forum folder or in the servers root folder?
Got it to work :)
i had to go the other way and use this part, same a Ray i guess?
The quote folder i have in the FORUM folder together with the themes and all the other forum things
//Put this in a phpbox/block//
//*--------------------------------------//*
include "./quote/randomquote.php";
//*--------------------------------------//*
And change the randomquote.php to this
<?php
/* Config Part --------------------------------------------------------------------------------------------------------------*/
$random = true;
$directory = "./quote/"; //Put the correct path//
$quotefile = "randomquote.inc"; //Add all quotes in this file in one line//
$quotecountfile = "displayquote.inc"; //This counts quotes, could be optionable if random is set false//
/* End of Config Part -------------------------------------------------------------------------------------------------------*/
So now i can go to bed a feel good about have this working now :)
Quote from: Ray on February 22, 2006, 03:15:53 PM
Quote from: ÂÃ,»cripÂÃ,« on February 22, 2006, 12:20:04 AM
<p align="center"><? php quotes ?></p>
or
<center>
<? php quotes
?>
</center>
I fixed it and had to do it in the randomquote.php file
and all the trouble I had and it was just becaue the php after the <? was not their
Thanks for that Ray I had that same problem I do believe and the include statement was wrong. Thanks for the whole centering thing.
And CRIP I GOT IT TOO WORK! MUAHAHA
*cough*cough*
haha
You can use your own quotes mitch, one line at a time..the more you have the more random they become.
Quotes :
http://lachlan.bluehaze.com.au/deep.html
Oh that works I was just going to ask members to start donating me some!
LOL!!! Now I can't get it to work...
Went through all the posts and nothing... Probably path related. I will go check some more.. ;D
See here
Quote from: L1played with this a long time and I know nothing about code but was getting the same error that ray has here, basically showing the code from randomquote.php instead of a quote. I got it to work by doing this:
$directory = "./quote/"; //Put the correct path//
and this
include "./quote/randomquote.php";
why that works I have no idea
maybe something to do with server setting?
great little mod, I love it
thanks alot
Make aure the PHP in in the file randomquote.php <?php
The Random Quote can be added many different ways actually. ;)
Why is it that something which should be relatively simple isn't? Had a dickens of a time trying to get this to work. Finally, created a 2nd phpblock, inserted the exact same code I had been inserting all along and it worked (and then deleted the 1st block). ?? I was almost at the point of this particular quote:
"If at first you don't succeed, destroy all evidence that you tried."
Parse error: parse error, unexpected $ in /home/georgeli/public_html/smf/Sources/Load.php(1609) : eval()'d code(34) : eval()'d code on line 1
thats AFTER i place in this code
ok fixed that....now its not showing
http://georgelittle.2plans.com/smf (its a center block)
could it be because some of my quotes dont fit on one line?
All demos i found on this pages do not work :'(
Is it because you all removed it and gave up on it???
I'd like a block like this... can't be that difficult? Just need a piece of code that pics a random line from a txt file and spits it out?
i had it just to test this one,and it worked on my board, same on most people that tried this snippet. it worked but arent all that fynny ;)
hey guys.
I'm just wondering how I can format the text in the qoute file, like line break or making some part of the qoute bold or italic etc.
Thx in advance!
l00p,
Quote from: l00p on June 07, 2006, 10:16:20 PM
hey guys.
I'm just wondering how I can format the text in the qoute file, like line break or making some part of the qoute bold or italic etc.
Thx in advance!
l00p,
This one lets you format the Quotes...
http://www.tinyportal.net/smf/index.php?topic=4989.0
It works with this script also, it was me that used BBcodes in stead of the PHP codes "<.br>" "<.b>" etc. My fault :$
Thx for the replay Crip.
Hi, i have this errors:
http://www.comunidad.than.org.es/index.php?topic=882.msg5254
2: (null)(): Failed opening 'â€Ã...“RandomQuotephpâ€Ã,Â' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php')
Archivo: /home/thanco/public_html/comunidad/Themes/default/Display.template.php (eval?)
LÃÆ'Ã,Ânea: 1
I test with phpquotes, but same error
Shouldn't RandomQuotephp read RandomQuote.php ??
Solved in other message,, thanks to all. :D
Hi all,
I know its not a snippet as such, but regarding the random quotes i use this
http://feeds.feedburner.com/brainyquote/QUOTEBR
From http://www.brainyquote.com/quotes/type/type_celebrity.html
Its along the same lines only not customisable...still very good though
Hope it helps :)
Thanks for the good link. ;)
Works like a charm :D
ive got pretty extensive quotes and TP keeps on truncating it at line 463. so i always get an unexpected $end error on the phpbox. is there a way for the php code to call an external text file so i can have as many random quotes as i want?
dig,
my quotes are in an external - randomquotes.inc file..add as many as I want..up to 700 hundred or so now..
lol crip. u keep changing ur username to weird characters :D
crookiedeee like me.. :D
I tried all the suggestions here to get this to work. What worked for me was having my path as
../forum_folder/quote/
and the include to look like this:
include "../forum_folder/quote/randomquote.php";
and adding in the php after the <? at the beginning in randomquote.php. After that, it all played nice. Thank crip, nice lil snippet :P
IS there anyway to delay the quotes to lets say a day before a new one is generated?
No. Not if you're doing random quotes. You could set up the quotes differently so that there was a different quote for each day or would cycle through the quotes, no matter how many there are.
could just add one each day..Lol .. remove the one you already have & add 1 new one..coarse you'd need to do that daily..
QuoteNo. Not if you're doing random quotes. You could set up the quotes differently so that there was a different quote for each day or would cycle through the quotes, no matter how many there are.
So how would you do that? I want to have one quote each day, not random, but one specifiic, that I assign for that day. The deal is: I don't want to have to get online to change the quote dayly, rather for a whole week or month at once. ;D
I responded in the other topic where you asked that question.