Page 1 of 1

Includes with Strings?

Posted: Mon Dec 27, 2004 5:45 pm
by panoramical
To access the file $reverse[] refers to, it's here: http://nindsnet.com/db/home.inc
First problem is that where I first commented, $reverse[1]. This string reads as valid HTML, and it is an img link: <img src etc. etc.... However, the image doesn't display for some reason.
The second problem is that on my second comment, I can't seem to include that file. Why?
The link to my site is here: http://www.nindsnet.com/indexo.php
I'd be grateful for any help.

Code: Select all

$data = file('db/home.inc');
$reverse = array_reverse($data);
echo $reverse&#1111;0];
echo '
    </td>
    </tr>
<tr>
<td bgcolor="#CCCCCC">';
echo $reverse&#1111;1]; //$reverse&#1111;1] is a valid img src link to an existing image...that doesn't display for some reason on the page
$result = include("news/admin/content/$reverse&#1111;2]"); //Doesn't include..?
$result;
Thanks

Posted: Mon Dec 27, 2004 5:58 pm
by skehoe
You may want to try a print_r statement after the first line in your example to make sure you're getting the home.inc file read in the first place.

~Scott

Posted: Mon Dec 27, 2004 6:31 pm
by panoramical
I know it's being read, because it's displaying other stuff from the file too...

Posted: Mon Dec 27, 2004 6:42 pm
by skehoe
Yeah... I was kinda hoping you could post the result of that print_r so that I could see what's in there and maybe be able to help you out.

Posted: Mon Dec 27, 2004 7:01 pm
by panoramical
sure...sorry.

Code: Select all

Array ( &#1111;0] => View Comments &#1111;1] => nintendodsreleased.inc &#1111;2] => No Avatar  &#1111;3] => Nintendo DS Released (Posted by panoramical on Tuesday 28th of December 2004 01:12:05 AM) )

Posted: Mon Dec 27, 2004 7:53 pm
by Gonik
If the above var dump is the $data one, the reversed should be:

Code: Select all

Array
(
     &#1111;0] =&gt; Nintendo DS Released (Posted by panoramical on Tuesday 28th of December 2004 01:12:05 AM)
     &#1111;1] =&gt; No Avatar
     &#1111;2] =&gt; nintendodsreleased.inc
     &#1111;3] =&gt; View Comments
)
As we can see there is no valid img src link for $reverse[1].
Second, are you absolutely sure that there is actually a file named nintendodsreleased.inc in the exact directory you specified? (news/admin/content/).
Furthermore, try using fopen() for opening the file and not include(). include() should not be used to echo files but just for referencing php code.

Also use

Code: Select all

<? echo $varname; ?>
to display text to the browser. Not just the name of the variable followed by a semicolon.

Posted: Tue Dec 28, 2004 5:15 am
by panoramical
Ok, thanks.
I can't see why the image link is not valid, as if you go to the actual database file: http://nindsnet.com/db/home.inc then there is clearly a valid img src link there. The file I want to output also exists. I'll try using fopen.