PDA

View Full Version : whats wrong with this count script


shopwithdan.com
05-17-2005, 01:46 AM
I want to display the total words in two files. The .txt files have one word per line. Fix this code please.


<html>
<head>
<title></title>
</head>


<body>
<?php
$file = "http://www.droplister.com/cgi-bin/dom_list1.txt";
$file1 = "http://www.droplister.com/cgi-bin/dom_list2.txt";

$lines = count(file($file));
$lines1 = count(file($file1));
$count = $lines + $lines1;

echo '$count words are used to generate these domains';
?>
</body>
</html>

Fou-Lu
05-17-2005, 02:11 AM
And... the problem is?
What errors are you receiving? What is your output vs your desired output?
All I can see off hand is that you cannot use your $count variable where it is echoed, you will simply see the word $count. To get around that you need:

echo $count . ' words are used to generate these domains';

however, whether $count contains anything or not is another question....

shopwithdan.com
05-17-2005, 02:22 AM
www.droplister.com/tools/count.html

that has it but it doesnt do anything, its blank, and when i go to the source code its just shows the same thing its not, i think its called parsed

shopwithdan.com
05-17-2005, 02:45 AM
new question



<?php
$font ="Arial";
$fontsize ="6";
$textfile ="http://www.droplister.com/tools/dom_list1.txt";
$textfile2 ="http://www.droplister.com/tools/dom_list2.txt";
$textfile3 ="http://www.droplister.com/tools/dom_list3.txt";


echo "<font face=\"$font\" size=\"$fontsize\">";
$quotes = file("$textfile");
$quote = rand(0, sizeof($quotes)-1);
$quotes2 = file("$textfile2");
$quote2 = rand(0, sizeof($quotes2)-1);
$quotes3 = file("$textfile3");
$quote3 = rand(0, sizeof($quotes3)-1);
echo $quotes[$quote].$quotes2[$quote2].$quotes3[$quote3];
echo "</font>";
?>


the results are

text text2 text3 I want them to be texttext2text3, how do I do that

hemebond
05-17-2005, 02:47 AM
You're right, it's not being parsed. This is a problem with your server.

shopwithdan.com
05-17-2005, 02:50 AM
i fixed it http://www.droplister.com/tools/count.php

shopwithdan.com
05-17-2005, 03:06 AM
i figure out one thing and run in to another wall, can i put that number on an html page with require or include?

Fou-Lu
05-17-2005, 04:14 PM
You betcha, just as you said, create an include_once function to throw it where you want it to be.
As for the spacing problem, thats relative to your choice of function: file(). Due to that, you are required to trim() it, at least an rtrim().

Velox Letum
05-17-2005, 07:21 PM
Unless your server is parsing .html, I wouldn't suggest using an include in a pure html file.