TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 623
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 397
  • Total: 398
  • @rjen

Random Quotes

Started by crip, February 06, 2006, 04:35:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

crip

Directions in .zip & on first post on this thread.

Mitch

Did you just do that or have they been there?
I always feel so dumb around you guys. ^_-

crip

I put it there when I 1st posted it. :)


Mitch

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]

TwinsX2Dad

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 -------------------------------------------------------------------------------------------------------*/






crip

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?

Mitch

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?

G6Cad

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 :)

Mitch

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

This website is proudly hosted on Crocweb Cloud Website Hosting.