include

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&...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-24-2007
Jean Pierre Daviau
 
Posts: n/a
Default include

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


Reply With Quote
  #2 (permalink)  
Old 07-24-2007
Rik
 
Posts: n/a
Default Re: include

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
Reply With Quote
  #3 (permalink)  
Old 07-25-2007
up2trouble
 
Posts: n/a
Default Re: include


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

Reply With Quote
  #4 (permalink)  
Old 07-25-2007
Jean Pierre Daviau
 
Posts: n/a
Default Re: include

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



Reply With Quote
  #5 (permalink)  
Old 07-25-2007
Rik
 
Posts: n/a
Default Re: include

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
Reply With Quote
  #6 (permalink)  
Old 07-25-2007
Jean Pierre Daviau
 
Posts: n/a
Default Re: include

----------- 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));
?>


Reply With Quote
  #7 (permalink)  
Old 07-26-2007
Jean Pierre Daviau
 
Posts: n/a
Default Re: include

Nothing works.

The doc points that the function should be in the include. This
is not what I want.


Thanks.


Reply With Quote
  #8 (permalink)  
Old 07-26-2007
Rik
 
Posts: n/a
Default Re: include

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
Reply With Quote
  #9 (permalink)  
Old 07-26-2007
Jean Pierre Daviau
 
Posts: n/a
Default Re: include

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



Reply With Quote
  #10 (permalink)  
Old 07-26-2007
Jean Pierre Daviau
 
Posts: n/a
Default Re: include


On Xp I have all permissions and I set those folders for writing
and reading. Still does not work


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:45 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0