Re: calling external php file before <html> tag
From: Ben (crescent_au_at_yahoo.com)
Date: 08/30/04
- Next message: Dag Eilertsen: "Updating MySQL record"
- Previous message: gc: "Re: Fatal error: Call to undefined function mysql_connect() & Fatal error: Call to undefined function mysql_pconnect()"
- In reply to: Wes Spikes: "Re: calling external php file before <html> tag"
- Next in thread: duz: "Re: calling external php file before <html> tag"
- Reply: duz: "Re: calling external php file before <html> tag"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Aug 2004 18:46:07 -0700
"Wes Spikes" <MornThdr@NOSPAMverizon.net> wrote in message news:<3GdYc.640$O85.477@trnddc05>...
> include("file_path/file_name.php");
> function_name(arg1,arg2,[...],argX);
>
> Basically, you include the file, then call the function contained in the
> file.
>
Thanx Wes!
That's exactly what I did but it doesn't work...
My external php file is below (this sets a cookie):
<?php
function counter() {
$cookie_val = @$_COOKIE["user_ip"];
$counterfile = "counter";
$line = @file($conterfile);
if(!$cookie_val) {
setcookie("user_ip", "$_SERVER[REMOTE_ADDR]", time()+36000);
if ($line[0] == NULL) {
$line[0] = 0;
}
$line[0]++;
$cf = @fopen($counterfile, "w+");
fputs($cf, "$line[0]");
fclose($cf);
}
elseif ($cookie_val != "$_SERVER[REMOTE_ADDR]") {
$line[0]++;
$cf = @fopen($counterfile, "w+");
fputs($cf, "$line[0]");
fclose($cf);
}
}
?>
My main (calling) php file is like this:
<?php
include 'phpfunc.php';
counter();
?>
<html>
<head></head>
<body></body>
</html>
I get the following warning:
Warning: Cannot modify header information - headers already sent by
(output started at D:\Apache Group\Apache2\htdocs\phpfunc.php:26) in
D:\Apache Group\Apache2\htdocs\phpfunc.php on line 8
I also uncommented "include_path" in php.ini and added the path to my
localhost web server which is "D:\Apache Group\Apache2\htdocs\" but
nothing changed...
Hope this shows my problem more clearly..
Thanx!
Ben
- Next message: Dag Eilertsen: "Updating MySQL record"
- Previous message: gc: "Re: Fatal error: Call to undefined function mysql_connect() & Fatal error: Call to undefined function mysql_pconnect()"
- In reply to: Wes Spikes: "Re: calling external php file before <html> tag"
- Next in thread: duz: "Re: calling external php file before <html> tag"
- Reply: duz: "Re: calling external php file before <html> tag"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|