This is a discussion on include within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I created an include file with a listing of paths. --- snip ---- global $autoexec; $autoexec = "C:\backJP\autoexec.bat&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I created an include file with a listing of paths. --- snip ---- global $autoexec; $autoexec = "C:\backJP\autoexec.bat"; ect; --- snip ---- require_once('paths.inc'); function updateFichier(){ if (!$myBool = fopen ($autoexec, "a")) { echo "Cant create($autoexec)"; exit; .... } The include file is printed on screen The function exit with Cant create the file If I write function updateFichier(){ global $autoexec; $autoexec = "autoexec.bat"; ....... it works . . . Why? Thanks for your attention. Jean Pierre Daviau -- windows Xp asus p4 s533/333/133 Intel(R) Celeron (R) CPU 2.00 GHz Processor Radeon7000 0x5159 agp |
|
|||
|
On Tue, 24 Jul 2007 23:04:46 +0200, Jean Pierre Daviau <Once@WasEno.ugh>
wrote: > global $autoexec; > $autoexec = "C:\backJP\autoexec.bat"; > --- snip ---- > > require_once('paths.inc'); > function updateFichier(){ > if (!$myBool = fopen ($autoexec, "a")) { > echo "Cant create($autoexec)"; > exit; > } > > The include file is printed on screen > The function exit with Cant create the file > > If I write > function updateFichier(){ > global $autoexec; > $autoexec = "autoexec.bat"; This last line is not neccesary > ...... > it works . . . You obviously missed something in scopes. I suggest you read up on it: <http://www.php.net/global> This very example is explained over there. -- Rik Wasmus |
|
|||
|
I'm not an expert like the other guys, so I may be wrong. I had the same problem last night. I fixed it by changing the chmod on that directory to allow writing and reading. After I closed file, I changed the chmod again. fclose($out); $out = "index.php"; chmod("$out", 0644); if (!$out) { print("Could not change permissions"); exit; } If I'm wrong, sorry for leading down the garden path. Lynne |
|
|||
|
It seems that the include path are not considered as files.
is_file($autoexec) returns false I changed this: --- inc file ---- $autoexec = "auto.bat"; $path = "\n%path%=%path%;c:\php\php.exe"; ---- > --- snip ---- require_once('paths.inc'); function updateFichier(){ global $autoexec, $path; > if (!$myBool = fopen ($autoexec, "a")) { > echo "Cant create($autoexec)"; > exit; > } > > The include file is printed on screen > The function exit with Cant create the file |
|
|||
|
On Wed, 25 Jul 2007 16:32:17 +0200, Jean Pierre Daviau <Once@WasEno.ugh>
wrote: > It seems that the include path are not considered as files. > is_file($autoexec) returns false Do you have reading and/or writing right to C:\backJP ? I suspect that is the problem. Have you enabled error displaying with an appropriate error_reporting level? -- Rik Wasmus |
|
|||
|
----------- auto.inc --------
$autoexec = "auto.bat"; $path = "\n%path%=%path%;c:\php\php.exe"; ------------------ <? //"C:\Program Files\EasyPHP1-8\php\php.exe" -check-f auto.php require_once('auto.inc'); function updateFichier(){ global $autoexec, $path; if (!$myBool = fopen ($autoexec, "a")) { echo "Impossible de créer le fichier ($autoexec)"; exit; } if (is_writable($autoexec)) { if (fwrite($myBool, $path) === FALSE) { echo "Impossible d'écrire dans le fichier ($autoexec)"; exit; } fclose($myBool); }else{ echo "Le fichier $autoexec n'est pas accessible en écriture."; } return $autoexec; } $file = updateFichier(); $handle = fopen ($file, "r"); echo "\n\n"; echo fread ($handle, filesize ($file)); ?> |
|
|||
|
On Thu, 26 Jul 2007 16:36:54 +0200, Jean Pierre Daviau <Once@WasEno.ugh>
wrote: > Nothing works. > > The doc points that the function should be in the include. This > is not what I want. That's not what's wrong. You probably cannot create a file in C:\Program Files\EasyPHP1-8\php\ due to rights -- Rik Wasmus |
|
|||
|
I am on the command line how do I create the permission?
get_include_path() === .;C:\php5\pear I putted the file there and EasyPhp is not running. "Rik" <luiheidsgoeroe@hotmail.com> a écrit dans le message de news: op.tv2tnwltqnv3q9@metallium... > On Thu, 26 Jul 2007 16:36:54 +0200, Jean Pierre Daviau > <Once@WasEno.ugh> wrote: > >> Nothing works. >> >> The doc points that the function should be in the include. >> This >> is not what I want. > > That's not what's wrong. You probably cannot create a file in > C:\Program Files\EasyPHP1-8\php\ due to rights > -- > Rik Wasmus |
![]() |
| Thread Tools | |
| Display Modes | |
|
|