SearchSearch   

include

 
   Webmaster Forums (Home) -> PHP RSS
Next:  command line and get user input  
Author Message
Jean Pierre Daviau

External


Since: Aug 07, 2005
Posts: 208



(Msg. 1) Posted: Tue Jul 24, 2007 5:04 pm
Post subject: include
Archived from groups: alt>comp>lang>php (more info?)

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
Back to top
Rik

External


Since: Aug 08, 2006
Posts: 876



(Msg. 2) Posted: Tue Jul 24, 2007 11:13 pm
Post subject: Re: include
Archived from groups: per prev. post (more info?)

On Tue, 24 Jul 2007 23:04:46 +0200, Jean Pierre Daviau <Once RemoveThis @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
Back to top
up2trouble

External


Since: Jul 22, 2007
Posts: 19



(Msg. 3) Posted: Wed Jul 25, 2007 1:01 am
Post subject: Re: include
Archived from groups: per prev. post (more info?)

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
Back to top
Jean Pierre Daviau

External


Since: Aug 07, 2005
Posts: 208



(Msg. 4) Posted: Wed Jul 25, 2007 10:32 am
Post subject: Re: include
Archived from groups: per prev. post (more info?)

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
Back to top
Rik

External


Since: Aug 08, 2006
Posts: 876



(Msg. 5) Posted: Wed Jul 25, 2007 5:29 pm
Post subject: Re: include
Archived from groups: per prev. post (more info?)

On Wed, 25 Jul 2007 16:32:17 +0200, Jean Pierre Daviau <Once.TakeThisOut@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
Back to top
Jean Pierre Daviau

External


Since: Aug 07, 2005
Posts: 208



(Msg. 6) Posted: Wed Jul 25, 2007 5:29 pm
Post subject: Re: include
Archived from groups: per prev. post (more info?)

----------- 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));
?>
Back to top
Jean Pierre Daviau

External


Since: Aug 07, 2005
Posts: 208



(Msg. 7) Posted: Thu Jul 26, 2007 10:36 am
Post subject: Re: include
Archived from groups: per prev. post (more info?)

Nothing works.

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


Thanks.
Back to top
Rik

External


Since: Aug 08, 2006
Posts: 876



(Msg. 8) Posted: Thu Jul 26, 2007 4:39 pm
Post subject: Re: include
Archived from groups: per prev. post (more info?)

On Thu, 26 Jul 2007 16:36:54 +0200, Jean Pierre Daviau <Once DeleteThis @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
Back to top
Jean Pierre Daviau

External


Since: Aug 07, 2005
Posts: 208



(Msg. 9) Posted: Thu Jul 26, 2007 4:39 pm
Post subject: Re: include
Archived from groups: per prev. post (more info?)

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.DeleteThis@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.DeleteThis@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
Back to top
Jean Pierre Daviau

External


Since: Aug 07, 2005
Posts: 208



(Msg. 10) Posted: Thu Jul 26, 2007 4:39 pm
Post subject: Re: include
Archived from groups: per prev. post (more info?)

On Xp I have all permissions and I set those folders for writing
and reading. Still does not work
Back to top
6eWmA67gxAebq

External


Since: Aug 25, 2007
Posts: 1



(Msg. 11) Posted: Sat Aug 25, 2007 12:17 pm
Post subject: Re: include
Archived from groups: per prev. post (more info?)

On 26 juil, 12:42, "Jean Pierre Daviau" <O....RemoveThis@WasEno.ugh> wrote:
> 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" <luiheidsgoe....RemoveThis@hotmail.com> a écrit dans le message denews: op.tv2tnwltqnv3q9@metallium...
>
>
>
> > On Thu, 26 Jul 2007 16:36:54 +0200,JeanPierreDaviau
> > <O....RemoveThis@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- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

The solution is to enclose the .inc variables in between <??>¨
--------- path.inc ---------------
<?php
$autoexec = "auto.bat";
$path = "\n%path%=%path%;c:\php\php.exe";

--------- eof path.inc ---------------
?>
Back to top
Display posts from previous:   
       Webmaster Forums (Home) -> PHP
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum