Random Quote block error.......

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drujr
Forum Newbie
Posts: 17
Joined: Thu May 13, 2004 1:59 pm

Random Quote block error.......

Post by drujr »

Heres teh code:

Code: Select all

<?php

## put an empty line between each quote for this to work... 
## i.e.  random.txt:
## quote1 quote1 
## quote1 quote1
##
## quote2 quote2
## 
## quote3 quote3

$textfile ="/home/drujr/public_html/random.txt"; 

$f = implode('', file("$textfile"));
$quotes = explode("\n\n", $f);
$quote = rand(0, sizeof($quotes)-1);
$tmp = str_replace("\n", "<br>\n", $quotes[$quote]);
$content = $tmp;


?>
Heres the error i'm seeing:

Warning: file(/www/random.txt): failed to open stream: No such file or directory in /home/drujr/public_html/blocks/block-random_quote.php on line 14

Warning: implode(): Bad arguments. in /home/drujr/public_html/blocks/block-random_quote.php on line 14



ideas?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

/www/random.txt wasn't found or couldn't be opened.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

...the path to your file is incorrect, or the file doesnt exist.
Post Reply