10-06-2003, 09:12 PM
$thefile = fopen("ipgrabber.txt");
fwrite($thefile, getenv("REMOTE_ADDR") . "\n");
echo " wrote to $thefile";
Everything looks right to me, but I get this error
Warning: Wrong parameter count for fopen() in c:\ibserver\www\ipgrabme.php on line 2
Warning: fwrite(): supplied argument is not a valid File-Handle resource in c:\ibserver\www\ipgrabme.php on line 3
Warning: fclose(): supplied argument is not a valid File-Handle resource in c:\ibserver\www\ipgrabme.php on line 4Thanks for any and all help!!
10-06-2003, 09:26 PM
when using fopen() you need to specify what you are opening the file for read, write, append ... This link may help.
this should work :
$thefile = fopen("ipgrabber.txt", "w+");
$thefile = fopen("ipgrabber.txt", "a+");
This should take care of the rest of the errors.
10-06-2003, 10:38 PM
Okay. That works!!
Now, I'm including it in my index page so that the users ip and user agent is being wrote to the file by this
$file = "./php-bin/ipgrabme.php";
?>but I then get this error. I am accessing this in another folder, so would it be ../ or ./ that would be causing these errors. I get different errors using ../ and ./
Warning: Unable to access ./php-bin/ipgrabme.php in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/categories.php on line 19
Warning: Failed opening './php-bin/ipgrabme.php' for inclusion (include_path='.:/usr/local/psa/apache/lib/php') in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/categories.php on line 19
10-07-2003, 12:56 AM
/ is the root directory, ../ means the previous directory, ./ means this directory in a seperate folder, similar to just plain / hope all that helps....
10-07-2003, 02:41 AM
This is the error I get using ../php-bin/ipgrabme.php
This is the error I get using ./php-bin/ipgrabme.php
The code works fine until I want to include it!
10-07-2003, 09:19 PM
Well if it is in another folder where is the relationship to that folder from the directory your index page is in?
lets say this is the directory where your index page is:
and the file you want to include is in this directory:
then your include statement in your index.php page should look like this:
include("include_files/filename"); or include("/include_files/filename") notice there is not . in front of the / for this one.
I have found that sometimes you need to play with your slashes and dots, i hve found that different servers and configurations can determine how it translates that. I have also found the servers mood to be a determining factor as well :) hope that helped you some.
10-10-2003, 07:58 PM
After noodling around on your site you should be able to put this in and have it work.
$file = "../php-bin/ipgrabme.php";
the php-bin directory is in a directory below your include direcotry. The reason you are getting a permissions error is more than likely you are trying to go to a directory that does not exist and your server is not liking it.... The above code should fix your problems.
10-11-2003, 03:46 AM
Gee, I wish --
Warning: fopen("ipgrabber.txt", "a+") - Permission denied in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/php-bin/ipgrabme.php on line 2
Warning: fwrite(): supplied argument is not a valid File-Handle resource in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/php-bin/ipgrabme.php on line 3
Warning: fclose(): supplied argument is not a valid File-Handle resource in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/php-bin/ipgrabme.php on line 4
You need to set your permissions.... chmod 777 the file.