For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > August 2007 > include









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author include
Jean Pierre Daviau

2007-07-24, 6:59 pm

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


Rik

2007-07-24, 6:59 pm

On Tue, 24 Jul 2007 23:04:46 +0200, Jean Pierre Daviau <Once@WasEno.ugh>=
=

wrote:
> global $autoexec;
> $autoexec =3D "C:\backJP\autoexec.bat";


> --- snip ----
>
> require_once('paths.inc');
> function updateFichier(){
> if (!$myBool =3D 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 =3D "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
up2trouble

2007-07-24, 9:58 pm


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

Jean Pierre Daviau

2007-07-25, 6:58 pm

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



Rik

2007-07-25, 6:58 pm

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
Jean Pierre Daviau

2007-07-25, 6:58 pm

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


Jean Pierre Daviau

2007-07-26, 6:59 pm

Nothing works.

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


Thanks.


Rik

2007-07-26, 6:59 pm

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
Jean Pierre Daviau

2007-07-26, 6:59 pm

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:
>
>
> That's not what's wrong. You probably cannot create a file in
> C:\Program Files\EasyPHP1-8\php\ due to rights
> --
> Rik Wasmus



Jean Pierre Daviau

2007-07-26, 6:59 pm


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


6eWmA67gxAebq@jeanpierredaviau.com

2007-08-25, 6:59 pm

On 26 juil, 12:42, "Jean Pierre Daviau" <O...@WasEno.ugh> wrote:
> I am on the command line how do I create the permission?
>
> get_include_path() =3D=3D=3D .;C:\php5\pear
> I putted the file there and EasyPhp is not running.
>
> "Rik" <luiheidsgoe...@hotmail.com> a =E9crit dans le message denews: op.t=

v2tnwltqnv3q9@metallium...
>
>
>
>
>
>
>
> - Afficher le texte des messages pr=E9c=E9dents -


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

--------- eof path.inc ---------------
?>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com