firekiller15
asked on
Why i failed to called my config file
PHP
Why i failed to called my config file
below is my code
config.php
######LOG#########
$fileHandle = fopen("c:\ERI.log", "a");
Logic.php
#######LOG FILE#############
function LogFile($string)
{
require_once("config.php") ;
$str = $string;
if (fwrite($fileHandle, $str))
echo "<br>Wrote to file \n </br>";
else
echo "write failed. \n";
fclose($fileHandle);
}
#######log testing to file#########
function Testing2()
{
$timestamp = time();
$string = date("l[H:i:s]", $timestamp)."stop process \r\n ";
return $string;
}
$newERI->LogFile($newERI-> Testing1() );
if i write $fileHandle = fopen("c:\ERI.log", "a"); i received this error
Warning: fwrite(): supplied argument is not a valid stream resource in C:\wamp\www\testing.php on line 385
write failed.
Warning: fclose(): supplied argument is not a valid stream resource in C:\wamp\www\testing.php on line 389
Why i failed to called my config file
below is my code
config.php
######LOG#########
$fileHandle = fopen("c:\ERI.log", "a");
Logic.php
#######LOG FILE#############
function LogFile($string)
{
require_once("config.php")
$str = $string;
if (fwrite($fileHandle, $str))
echo "<br>Wrote to file \n </br>";
else
echo "write failed. \n";
fclose($fileHandle);
}
#######log testing to file#########
function Testing2()
{
$timestamp = time();
$string = date("l[H:i:s]", $timestamp)."stop process \r\n ";
return $string;
}
$newERI->LogFile($newERI->
if i write $fileHandle = fopen("c:\ERI.log", "a"); i received this error
Warning: fwrite(): supplied argument is not a valid stream resource in C:\wamp\www\testing.php on line 385
write failed.
Warning: fclose(): supplied argument is not a valid stream resource in C:\wamp\www\testing.php on line 389
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you probably have a scope problem. put
global $fileHandle;
in both scripts.
global $fileHandle;
in both scripts.
ASKER
Warning: fwrite(): supplied argument is not a valid stream
if i put $fileHandle = fopen("c:\ERI.log", "a"); in "log testing to file.php" not in config.php the error message will not appear