homepage Welcome to WebmasterWorld Guest from 54.211.213.10
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Odd as hell error
I dunno what the problem is.
Echo_Tyme




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

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>

<br>
<br>

(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]

 

jatar_k




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

what's this?

SITE SITE

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.

Echo_Tyme




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

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.

Adrian2k4




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

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

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

Echo_Tyme




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

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

Birdman




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

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');

Birdman

Echo_Tyme




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

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.

coopster




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

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";

Echo_Tyme




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

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:

<?
include("/v5/top.php");

$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?

coopster




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

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.
Echo_Tyme




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

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.

Echo_Tyme




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved