beginning_php thread: Help with Counter File
Message #1 by Gene Ingraham <n2bim@w...> on Thu, 27 Feb 2003 08:10:28 -0500|
Hello to the group,
First, I'm new to this group and to PHP, and I could use a little help,
if it's available. I am an accountant by trade, and not an IT
professional, nor am I a programmer, so please bear with me if my
mistake is obvious. Thanks!
I've been trying to add a new counter file to the home page of a site
that I administer.
1 - I added a blank file called counter.dat to the directory.
2 - I added the following code to the index.html file and renamed the
file to index.php:
<?PHP include ("count.php?show=true");
3 - I added a file called count.php with the following code:
$file = "counter.dat"; // counter file
if(!($fp = fopen($file, "r"))) die ("Cannot open $file.");
$count = (int) fread($fp, 30);
echo "You're visitor Number <b>$count</b>.";
$fp = fopen($file, "w");
4 - I set the permissions on these files using CHMOD to Read/Write
(but not Execute). I suspect there may be a problem with that,
but I'm not sure.
When I open the page, I get the following:
Warning: Failed opening 'count.php?show=true' for inclusion
/usr/local/www/virtual/scarcnj/www.scarcnj.org/index.php on line 162
The server that this site is running is using UNIX, with the latest PHP
Can anybody tell me where the problem is?
Message #2 by "Pedro Graca" <bzzzt@f...> on Thu, 27 Feb 2003 13:18:10 +0000|
On Thu, 27 Feb 2003 08:10:28 -0500, Gene Ingraham said:
> <?PHP include ("count.php?show=true");
> When I open the page, I get the following:
> Warning: Failed opening 'count.php?show=true' for inclusion
> (include_path='.:/usr/local/lib/php') in
> /usr/local/www/virtual/scarcnj/www.scarcnj.org/index.php on line 162
hmmmm ... I'm not sure, but try this instead
$show = true;
() ribbon campaign ()
/\ against HTML mail /\
Message #3 by "Nikolai Devereaux" <yomama@u...> on Thu, 27 Feb 2003 10:49:40 -0800|
> > <?PHP include ("count.php?show=true");
> hmmmm ... I'm not sure, but try this instead
> $show = true;
> include "count.php";
Pedro's correct. include() thinks that "count.php?show=true" is the
filename that you're trying to open. It's an invalid filename, and the
filesystem would complain that it couldn't open the file.
Pedro's solution works because include() basically inserts the included
file's contents in-place in the current document. Therefore, any variables
that are in scope of the includING file are also in scope for the includED