|
Posted by Hilarion on 09/05/05 21:08
ScareCrowe <nospam@nospam.com> wrote:
> Okay, I got it working, but how I did raises another querstion. The script
> is called from another page, which has it as a PHP include, like so:
>
> include("mypage.php");
>
> I fixed it by specifying the full path to the include func line so:
>
> include("http://www.domain0.com/mypage.php");
>
> Why would the script execute the for() loop twice when it is called as it is
> in my first example, and once when it is called in the second?
>
> I read the documentaion for include() on the php site, but I still don't
> have a satisfactory answer.
It's probably not "include" instruction fault. It's the way the http wrapper
used works. I suppose it does it like this:
It queries the URL for headers (HEAD method) to get the size or type (etc.)
of the document, which - in case of PHP files - causes execution of the script,
and then it queries the URL for output (GET method), which causes second
execution of the script.
You should not use "include" with URLs if they point to local PHP scripts.
There's nothing better in using URLs in this case.
Going back to the oryginal problem - did the doubled entries appear
in the file one after another or there was one series of entries and
another series of entries? The second case it suggests that the script
is simply executed twice. Have you tried running the oryginal script
from command line? Was the result doubled in this case too?
Hilarion
Navigation:
[Reply to this message]
|