Include and arrays
Slight problem with pulling data from arrays stored in an included file. If I store the arrays in the same PHP file that is displaying the information, this works fine, but when I store the arrays in a seperate file and include() it, it can't find the data. I'm trying to keep all the arrays in one file by themselves to make changing things easier. Here's what I have come up with.
This is an excerpt from index.php
This is from arrays.php
Purpose: Draw body text
<?php include('arrays.php'); ?>
<table width="100%" border="0" cellspacing="5" cellpadding="2">
<td class="body2" height="100">
for ( $i = 0; $i <= $warders; $i++ )
Thanks in advance for any advice.
$warArray = 'Asandir';
$warArray = 'Caellach';
$warArray = 'Caldamus';
$warArray = 'Drizzt';
$warArray = 'Flarn';
$warArray = 'Jaryd';
$warArray = 'Kale';
$warArray = 'Kodel';
$warArray = 'Kordac';
$warArray = 'Lanth';
$warArray = 'Makojin';
$warArray = 'Mallagant';
$warArray = 'Mica';
$warArray = 'Narival';
$warArray = 'Navvar';
$warArray = 'Phostan';
$warArray = 'Rance';
$warArray = 'Ransard';
$warArray = 'Rylas';
$warders = count( $warArray );
I just copied and pasted your coding and it ran just fine. Is that happening on your web hosts server or a development server you are running at home?
It's happening on both my dev box and my server. Thinking it may be a global setting kind of thing?
Possibly. Firepages my fellow mod may be able to shed some light on that area.
To avoid the possibility I might have overlooked something small ( entirely possible ), I tried adding this into the index.php
I received all three errors on page load. :eek:
$success = @include('arrays.php');
if ( !$success )
echo "Could not include the arrays file. Trying another method.";
$again = @include('/home/aww/public_html/tm/arrays.php');
if ( !$again )
echo "Could not include the arrays file again.";
$useroot = @include( $DOCUMENT_ROOT . 'arrays.php');
if ( !$useroot )
echo "Tried using the doc root that time. No go.";
sorry, but like Spooks I can see no reason why that code would not work under any circumstances unless there was a problem with the include path in the php.ini, in saying that I see you tried the absolute path which should work in anycase.
I used include './sample_array.txt';
but all of your methods should have worked with the possible exception of $DOCUMENT_ROOT which may give a misleading value in a script aliased directory (and is best now accessed via $_SERVER[DOCUMENT_ROOT]
try running this to see if your include path has anything strange in it
It just returned the path to the php installation.
It works by locating the arrays within the index.php, so I'll stick with that. Thanks for the help. :)