Click to See Complete Forum and Search --> : Error Help


Jick
07-15-2003, 01:42 AM
-----------------------------------------------------------------
I'm getting this error here:

Warning: main(): stream does not support seeking in /home/infini15/public_html/kd7pyo/index.php on line 2

On this page:

http://kd7pyo.infinitypages.com/

Here is the top of my "index.php" and the bold line is line two of my "index.php" file:

<?PHP
include ("http://kd7pyo.infinitypages.com/online.php");
?>
<html>
<head>
<title>The Dandy Group</title>
etc...
-----------------------------------------------------------------

So how can I fix this? Please help! ;)

AdamGundry
07-15-2003, 03:44 AM
The reference to main() is actually a reference to an error in include() - see http://www.php.net/main. I've never had this error before, but it could be because of the version of PHP on your system.

From the manual (http://www.php.net/manual/en/function.include.php):Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via [include]Adam

Jick
07-15-2003, 04:36 PM
Well since it is on Pyro's server maybe he can shine some light on the matter. I would greatly appreciate it if Pyro did help me out a bit on this. I think something may have been changed on the server since it worked before. Thanks. :D

brendandonhue
07-15-2003, 04:41 PM
its hosted on DR2. Dr2 just did some major security upgrades, causing problems with includes and MIME types.
You might want to check out the forums at dr2.net/vB for more info.
Now on DR2 you must use relative paths to your include files, not the full path.

pyro
07-15-2003, 04:43 PM
Try linking to the file differently. Something like this, perhaps:

include ("online.php");

[edit - Ah, I see brendandonhue beat me...]

brendandonhue
07-15-2003, 04:45 PM
Yes, but I was worried for a second that you were doing it on a reseller account and maybe you didn't want it posted that it was on DR2.
Phew :)

pyro
07-15-2003, 04:48 PM
lol... Well, he's coasting along on a freebe account, but yes, I do have a reseller account there... :D

brendandonhue
07-15-2003, 04:49 PM
I know what ya mean-Im only using half my space and a dot of bandwidth there so I'm hosting guestbooks for 2 friends :D

pyro
07-15-2003, 04:51 PM
dr2 is great... Space there is almost free... (just don't tell the people who I actually have paying... :p ) lol...

brendandonhue
07-15-2003, 04:54 PM
LOL! But now its $40 bux instead of $20 for the value plan :(
Props to matt for letting current users renew at the old price though :cool:

Jick
07-15-2003, 07:32 PM
I did what you said and now my main index file is working properly. I now get this error on my search page which I have the same include on:

Warning: main(): stream does not support seeking in /home/infini15/public_html/kd7pyo/search/index.php on line 2

My search page is not in the same dir as my main index file. Is there a code I could put in to link my search page that is not in the same dir to my online.php file? I think I have to insert a special code or something into my php include. Please help. :(

brendandonhue
07-15-2003, 07:53 PM
include ("./online.php");

pyro
07-15-2003, 10:38 PM
Should be two dots...

include ("../online.php");

Jick
07-15-2003, 10:38 PM
I did what you said and I now get this error:

Warning: main(./online.php): failed to open stream: No such file or directory in /home/infini15/public_html/kd7pyo/search/index.php on line 2

Warning: main(): Failed opening './online.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/infini15/public_html/kd7pyo/search/index.php on line 2

I wunder what could be wrong? Is there something else I can try? Thanks. :D

pyro
07-15-2003, 10:43 PM
Try my above post...

Jick
07-15-2003, 11:17 PM
I think that fixed that problem but now I'm getting this error:

Warning: Invalid argument supplied for foreach() in /home/infini15/public_html/kd7pyo/online.php on line 68

Here is my online.php file:
<?PHP

$file = "online.txt"; #chmod to 666
$logfile = "log.txt"; #chmod to 666 -- used for log file
$minutes = "1"; # number of minutes until users are no longer online

$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$data = "";
$users = "0";
$found = "0";

#set up log file data

$logtime = date("h:ia");
$logdate = date("m/d/y");

$logdata = "($ip | $logtime | $logdate)\n";

if (!isset($_COOKIE["logged"])) { #if cookie is not set
#write log file
$fp = fopen($logfile, "a");
fwrite ($fp, $logdata);
fclose ($fp);
setcookie ("logged", "visited", time() +"1200"); #set for 20 minutes (time is in seconds)
}

$lines = @file($file);

$contents = @split("\|", $lines[0]); #split the first line of the file
if (count($lines) == 0) { #if file is empty
$x = 0;
}
else { #if there is already data in the file
$x = 1;
}

$fp = fopen($file, "w");
if ($x == 1) {
foreach ($contents as $content) { #loop through the users
list ($savedip,$savedtime) = split(":", $content); #list the users ip's and last time on page
if ($ip == $savedip) { #user already online, update time
$data .= "$ip:$time|";
$users++;
$found = "1";
}
else {
if ($time < $savedtime + ($minutes * 60)) { #other users online, don't update time
$data .= "$savedip:$savedtime|";
$users++;
}
}
}
}
if ($found == 0 or $x == 0) { #first time this user came online
$data .= "$ip:$time|";
$users++;
}

$data = substr($data, 0, -1); #cut off the trailing |
fwrite($fp, $data); #write the file
fclose ($fp);

$file = "log.txt"; #file to open/write to
$lines = "20"; #number of lines to read
$data = "";
$content = @file($file);
foreach ($content as $line_num => $line) {
if ($line_num < $lines) {
$data .= $line;
}
else {
$data = "";
}
}
$fp = fopen($file, "w");
fwrite($fp, $data); #write the file
fclose ($fp);
?>
I'm not sure whats wrong?

Jick
07-16-2003, 02:14 AM
They must be doing server updates because it works with no errors now! Hmm... I wunder what they were doing?