Home > Archive > PHP Language > September 2006 > Help with array / 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 |
Help with array / include
|
|
| Marnok.com 2006-09-03, 7:56 am |
| My problem is this.
I have a php file (file_a) which has:
an array;
a function which picks a random element from that array and echoes the
content;
a call to that function.
I also have another file_b with
include $_SERVER['DOCUMENT_ROOT'].'file_a.php'
and some other content around this.
When I load file_a direct into my browser, if picks the element just fine.
When I load file_b, it says there is no data in the array. It ony does this
when file_a is in a different folder on my server : if they are both in
root, it works fine. When file_a is in root and file_b is in "root/content",
it fails - file_a is included but I get an error from within the code
indicating that the array is empty.
Can anyone give me any clues? I will try making a simplified version to see
if I can work out what's wrong. but it sound as though something like this
might be a "known" thing (ie I didn't rtfm diligently enough)
--
http://www.marnok.com - if you liked this post, visit me at home!
========================================
===================
| |
| Marnok.com 2006-09-03, 7:56 am |
|
"Marnok.com" <wizardharry@pottermarnok.com> wrote in message
news:q_-dnbs_lcR_LWfZnZ2dnUVZ8qqdnZ2d@giganews.com...
> My problem is this.
>
> I have a php file (file_a) which has:
> an array;
> a function which picks a random element from that array and echoes the
> content;
> a call to that function.
>
> I also have another file_b with
> include $_SERVER['DOCUMENT_ROOT'].'file_a.php'
> and some other content around this.
>
> When I load file_a direct into my browser, if picks the element just fine.
>
> When I load file_b, it says there is no data in the array. It ony does
> this when file_a is in a different folder on my server : if they are both
> in root, it works fine. When file_a is in root and file_b is in
> "root/content", it fails - file_a is included but I get an error from
> within the code indicating that the array is empty.
>
> Can anyone give me any clues? I will try making a simplified version to
> see if I can work out what's wrong. but it sound as though something like
> this might be a "known" thing (ie I didn't rtfm diligently enough)
>
> --
> http://www.marnok.com - if you liked this post, visit me at home!
> ========================================
===================
>
Actually, I have tested the simple version and the idea is fine... there
must be something wrong with my actual pages.
Maybe because I have a php file whcih includes an htm file, which includes
the file_a.php - perhaps I am overcomplicating things?
--
http://www.marnok.com - if you liked this post, visit me at home!
========================================
===================
| |
|
| On Sun, 3 Sep 2006 11:39:30 +0100, "Marnok.com" <wizardharry@pottermarnok.com> wrote:
>My problem is this.
>
>I have a php file (file_a) which has:
>an array;
>a function which picks a random element from that array and echoes the
>content;
>a call to that function.
>
>I also have another file_b with
>include $_SERVER['DOCUMENT_ROOT'].'file_a.php'
>and some other content around this.
>
>When I load file_a direct into my browser, if picks the element just fine.
>
>When I load file_b, it says there is no data in the array. It ony does this
>when file_a is in a different folder on my server : if they are both in
>root, it works fine. When file_a is in root and file_b is in "root/content",
>it fails - file_a is included but I get an error from within the code
>indicating that the array is empty.
>
>Can anyone give me any clues? I will try making a simplified version to see
>if I can work out what's wrong. but it sound as though something like this
>might be a "known" thing (ie I didn't rtfm diligently enough)
check your permissions on file_b
| |
| Andrew Bailey 2006-09-03, 9:56 pm |
| Hi Gleep,
I don't know if this will help but I have a similar scenario...
I call a php file from root/includes/layout, that file then includes an a
php file with an array from root/includes/layout/nav.
The array contains urls and each one either has to be literal (eg:
http://www.someplace.com/blah/blah) or relative TO THE ORIGINAL CALLED PHP
FILE eg ../../ to get to root even though the included file with the array
is ../../../ to get to root and the original html file could be any where.
Hope this helps you
Andy
"Gleep" <Gleep@Gleep.com> wrote in message
news:aopmf2t9inggah5r4h9fftva3vcbsmmcdp@
4ax.com...
> On Sun, 3 Sep 2006 11:39:30 +0100, "Marnok.com"
> <wizardharry@pottermarnok.com> wrote:
>
>
>
>
> check your permissions on file_b
| |
| Marnok.com 2006-09-04, 3:57 am |
|
"Andrew Bailey" <andy@idontwantanyspam.com> wrote in message
news:NzNKg.7343$G72.2910@newsfe3-gui.ntli.net...
> Hi Gleep,
>
> I don't know if this will help but I have a similar scenario...
>
> I call a php file from root/includes/layout, that file then includes an a
> php file with an array from root/includes/layout/nav.
>
> The array contains urls and each one either has to be literal (eg:
> http://www.someplace.com/blah/blah) or relative TO THE ORIGINAL CALLED PHP
> FILE eg ../../ to get to root even though the included file with the array
> is ../../../ to get to root and the original html file could be any where.
>
> Hope this helps you
>
> Andy
>
>
>
>
> "Gleep" <Gleep@Gleep.com> wrote in message
> news:aopmf2t9inggah5r4h9fftva3vcbsmmcdp@
4ax.com...
>
>
Hi thanks!
I eventually had to do a full 'http://www.domain.com/file_a.php' to make it
work (and add <html><body> to the php file)
but it works!
Whole thing was intended as a 5 minute job. Bah.
Now to glue my hair back in...
--
http://www.marnok.com - if you liked this post, visit me at home!
========================================
===================
|
|
|
|
|