Link to home
Start Free TrialLog in
Avatar of firekiller15
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
ASKER CERTIFIED SOLUTION
Avatar of mankowitz
mankowitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of firekiller15
firekiller15

ASKER

ehhh ... i receive an error message
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
you probably have a scope problem. put

global $fileHandle;

in both scripts.