Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

My member display list shows error in index.php

5:46 pm on Apr 13, 2012 (gmt 0)

If I pull up http://example.com/

In index.php...


<p> <?php print "$TKTedMemberDisplayList"; ?>

<div style="width:728px; height:827px; border: #999 thin solid; overflow:auto;"><?php print "$announcerDisplayList"; ?>


I get this one error in between a table and some pictures that show on my home page.

Notice: Undefined variable: TKTedMemberDisplayList in /home/*******/public_html/index.php on line 89 (should show members picture)

I use TKTedMemberDisplayList in other php pages and no problem.

However; If I pull up http://example.com/root/index.php The error is not there and the
TKTedMemberDisplayList shows members pictures.

Thanks in advance

[edited by: eelixduppy at 5:50 pm (utc) on Apr 13, 2012]
[edit reason] switched to example.com [/edit]

5:52 pm on Apr 13, 2012 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member

From what I can see, /index.php and /root/index.php are two different files. Can you tell me why I should believe otherwise?
6:52 pm on Apr 13, 2012 (gmt 0)

How did I get /index.php and /root/index.php from two diff files?

My index.php is located in my root folder.
7:20 pm on Apr 13, 2012 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member

As far as your web server is concerned, unless you have something going on behind the scene that I cannot see/am not aware of, these are two different locations...

There is a directory that your web server will recognize as the document root, let's say on your box it is this: /var/www

If you place a file here called index.php, it will have the absolute path on your box as this:


And be accessible via a browser at www.example.com/index.php

Now, let's say you create a directory, root, and place a file, index.php in it.

file is at: /var/www/root/index.php

and is accessible via a brower as www.example.com/root/index.php

So, unless you have some magic happening behind the scenes that is rewriting your url, they are referencing two different files. This will explain why you are getting different results.
6:18 pm on Apr 15, 2012 (gmt 0)

I'm using FileZilla to FTP my web pages under /public_html then /root. Some pages have root and some don’t. My web hosting company says, its better if I move my folders and files in to this location… /home/user/public_html. It sounds like too much work.

Thanks, Scott
8:54 pm on Apr 15, 2012 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member

So does this mean you have two different versions of the file then, as I said above?
7:06 pm on Apr 16, 2012 (gmt 0)

Heres my website with index.php http://www.example.com/index.php

Heres my website with root/index.php
* This one shows 2 diff pictures in my memebers section. This one is correct. But why doesnt it show the two diff images on http://www.example.com?

[edited by: eelixduppy at 8:07 pm (utc) on Apr 16, 2012]

8:10 pm on Apr 16, 2012 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member

Please do not post links to your personal website; this is not allowed -- See Forum Charter [webmasterworld.com]

Back to your question --

You are not providing enough information for me to help you. Also, you still have not answered my question. Without some insight as to how your code is writing the URIs for the images, I will not be able to help you.
5:38 pm on Apr 17, 2012 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

It sounds like too much work.

Yet, you don't realize what everyone is telling you - you've actually made it too much work by creating this folder "root."

I can't even fully extract the cause of the problem from your posts, but I can tell you what is wrong with a near mathematical certainty, because it's the same problem most PHP coders exhibit - even many experienced ones. This is going to be a path issue, and it's going to be because you're using relative links, as in "relative to where this file is."

First, take their advice and get RID of that "root" folder. Just drag everything out of it and in the root of your domain. Someone somewhere told you to "put files in the root directory." So you (or someone) created a folder named "root" and put some stuff in there. That is not what it means.

Root describes your domain's root, the root from where your domain tree begins, and it's different in different contexts. It's **really** important you understand this difference or you're always going to struggle with missing images, includes that don't include, and all kinds of other crap that you won't get because you're thinking "relatively."

The root URL/URI is the root of your domain when called from the web. It's simply /, or the fully qualified URL: http://www.example.com.
The file system root is a completely different animal. Yes, it is the root of your domain, but it's the computers' path to your domain root. You can see whatever this is, at any time, by running phpinfo() or doing this.


Using your example, this is /home/example.com/public_html. (using your domain or user name.) This is not a URL/URL, this is your domain's file system root.

Why is this important? Most PHP code you will see here, and in all the code you'll scrape off the web, does s**t like this: (and it IS! SORRY!)

<img src="img.jpg">
<img src="images/img.jpg">
<img src="../images/img.jpg">
<img src="../../../images/img.jpg">

Though it's particularly rampant in PHP, this insanity poisons CSS and Javascript as well:

background: url(../images/bg.jpg);

Note these carefully, we'll use the same examples later. What do all these have in common? The rely on relative paths, meaning, "Wherever I'm at now, step up or down to these directories and find this file." You can squeak along using this method, but the problem with it is that if something moves, you have to go back and modify all these instances, and you're constantly calculating "where you want to be from where I am now".

That's insane.

Complicate this once more: Many PHP coders treat PHP includes as URL's or URI's. They are not the same. PHP uses the file system path to include files, while URI's (images, other pages from a browser, whatever) use actual URI/URL's. Why do they do this?

Because it works one time, and they've no reason to believe it won't work forever. Which, as you're discovering, throws you into a tailspin when it doesn't.

In your case, You probably have the exact same file and have to figure out where that file is from the /root directory, then figure out where it is from the actual domain root. So if you have


and then from /root/index.php,
<img src="images/myfile.jpg">

No problem. It finds it. But if you have the same img code in the index.php at the actual domain root, of course it won't find it. It's in the /root/images/directory and this code

<img src="images/myfile.jpg">

is not descending into the "root" directory.

Now, don't run off to fix this by putting "root" in front of the "images" in the img src of domain root copy of index.php. That would be a patch that would eventually resurface in some other page or project. Here is a permanent fix.

Here is what you do: Locate all "web reference paths" and change them to this:

<img src="/img.jpg">
<img src="/images/img.jpg">
<img src="/images/img.jpg">
<img src="/images/img.jpg"> <!-- note that this is now exactly the same as the first two examples! -->

What does this do? It says "DOESN'T MATTER where I am now. Start at the domain root and follow this path."

For all PHP includes, do this.
include($_SERVER['DOCUMENT_ROOT'] . '/includes/file.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/file.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/file.php'); // Look at that, they are all the same!

This does the same thing, but form the file system path. "Start at the file system root of this domain and field this file."

Trust me, DO the work, get rid of that root folder, adopt this policy and this problem will go away forever.
9:47 pm on Apr 17, 2012 (gmt 0)

ATTN RocknBill - your a saint. I will give do this in the next few days and let you know how I did.

I've been following some tutorials online and that I was taught to build a root & script folder. I'm new to all this and just trying to build a social network website.

Thanks again,