Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Odd as hell error

I dunno what the problem is.



9:29 am on Sep 5, 2004 (gmt 0)

10+ Year Member

Get this... ok so i'm doing a php template, it's goign great, then I break into another directory and it can't read the file, understanable, it's setup as 'temp.php' ok. So I put it as "link/temp.php" and it's an error... I dunno what the hell just happened...

(Note: I realize the paragraph is stupid... I dunno how I wrote that with that many errors)

hrere's the code:


include('SITE SITE/top.php');

$title = "MM About";

$top = "$main";

$content = '

<p><snip> While being online, try to stay to "safe sites... <snip> keeping your
personal information (like bank information, credit numbers, etc) safe.</p>


(Note: This section will be built upon as more issues come to my eyes).';

include('SITE SITE/temp.php');


Oddly it brings up a variable can't be called (it's call in top.php). It's so odd that this just pops up. I have tried ' and " and even php require but NOTHING seems to want to do this. How can this be fixed?

Thank you.

[edited by: ergophobe at 2:43 pm (utc) on Sep. 5, 2004]
[edit reason] snipped excess text for readability [/edit]


12:30 pm on Sep 5, 2004 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

what's this?


is that a constant? spaces in a constant might cause a problem

if it stops working when you move to another dir you are having a path problem of some kind.


9:13 pm on Sep 5, 2004 (gmt 0)

10+ Year Member

no SITE SITE is a link to my site it's an http: .com so I can't put it. the directory is in the main directory so it's (my site)/top.php

yet it refuses to work.


9:33 pm on Sep 5, 2004 (gmt 0)

10+ Year Member

Why do you put in a absolute URI? ("http://www.(yoursite).com/script.php")

Try a relative URI: "./script.php"


12:00 am on Sep 6, 2004 (gmt 0)

10+ Year Member

Someone told me u have to have the full url in order for the php to read it.


12:18 am on Sep 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Actually, they probably meant the "full path", not absolute. The full path is usually something like /user/public_html/this_is_root/

Your best bet is to use this syntax:

include($_SERVER['DOCUMENT_ROOT'] . 'test.php');



2:21 am on Sep 6, 2004 (gmt 0)

10+ Year Member

I know the problem... it's not reading the variable.

I call up /v5/top.php.

In that file is a variable called $main. this variable has this info:

$main = '<div align="left"><img src="/images/top.gif" alt="Top Image"></div>';

Then the content page tells it this:

$top = '$main';

Then the template calls up this:

echo $top;

Now I dunno if that's the right thing. So far it's outputting $main, then displays the rest of the page.

It used to show the banner that it is supposed to. Now after i get the directory behind it... it doesn't want to. So what can possibly be the problem?

Oh ya I also had it call up an old page of mine and it displayed that fine (But it had no variable and it complained about that, but it's showing it).

And i dunno what ur code meant birdman.. u gotta reallly simplify it to almost exactly how i gotta put it lol.


3:47 am on Sep 6, 2004 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

I'm not sure if you actually have single quotes or not, but the variable won't be parsed unless it is enclosed in double quotes.
$top = "$main";


8:27 am on Sep 6, 2004 (gmt 0)

10+ Year Member

Well I didn't know about that, what about if i have echo $content. So far all my content is inclosed by ' and it's not causing any errors. It's alot easier then using "

Anyway now I have this:


$title = "My Title";

$top = "$guardian";

Easy, simple and also not the complete thing (content missing from my example). The error on the page reads (i hope this is ok):

Warning: main(/v5/top.php): failed to open stream: No such file or directory in C:\Inetpub\accounts\mm.intellstat\v5\index.php on line 2

Warning: main(): Failed opening '/v5/top.php' for inclusion (include_path='.;c:\php4\pear') in C:\Inetpub\accounts\mm.intellstat\v5\index.php on line 2

Notice: Undefined variable: guardian in C:\Inetpub\accounts\mm.intellstat\v5\index.php on line 6

So it can't find the file when it's /v5/top.php

and if that file isn't included it can't find the variable. I dunno what to do to fix this anymore... ideas?


12:21 pm on Sep 6, 2004 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

OK, I didn't quite mean it that way. The most important feature of double-quoted strings is the fact that variable names will be expanded. You can do variable assignment without quotes, too.
$top = $main;
But when you are using a variable in a quoted context, it won't get parsed within single quotation marks. Have a read of the Strings [php.net] page of the PHP manual for more information.

Going back to your bigger problem here...try setting the path back to the path that you believe is working for the include. Then, at the top of the included file, do a simple statement, such as

exit('You made it here!');
If your script stops and the message is displayed, we've confirmed that your include is working and we'll move on to variable scope [php.net] to try and figure out what's happening to your variable.


3:27 pm on Sep 6, 2004 (gmt 0)

10+ Year Member

i made the variable "main" into exit('You made it here!');

but taht didn't work, i also put it under the <? and that didn't work. It's just not finding it. In my older layout this method is fine, when I put the url (full) it acts fine like nothing is wrong, but now it's jsut being a pain.


8:34 pm on Sep 6, 2004 (gmt 0)

10+ Year Member

the host of the server told me how to fix this just now. I just use relative links (../v5/top.php) and it'll be just fine.

Featured Threads

Hot Threads This Week

Hot Threads This Month