Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MegaMan1311

macrumors regular
Original poster
Jun 30, 2007
216
0
USA
Odd. When I use <php include('/index.php');?> from mypage.php, it doesn't work. It doesn't like the slash. Shouldn't that work?

EDIT: Here is my error:
Warning: require() [function.require]: Unable to access /header.php in /var/www/vhosts/url/httpdocs/testing/server_root.php on line 2

Warning: require(/header.php) [function.require]: failed to open stream: No such file or directory in /var/www/vhosts/url/httpdocs/testing/server_root.php on line 2

Warning: require() [function.require]: Unable to access /header.php in /var/www/vhosts/url/httpdocs/testing/server_root.php on line 2

Warning: require(/header.php) [function.require]: failed to open stream: No such file or directory in /var/www/vhosts/url/httpdocs/testing/server_root.php on line 2

Fatal error: require() [function.require]: Failed opening required '/header.php' (include_path='.:') in /var/www/vhosts/url/httpdocs/testing/server_root.php on line 2


Thanks,
MegaMan1311
 
Makes sense... I edited your code to /httpdocs/header.php, but it still didn't work.

Error:

Warning: include() [function.include]: Unable to access /httpdocs/header.php in /var/www/vhosts/thecybernetwork.net/httpdocs/server_root.php on line 2

Warning: include(/httpdocs/header.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/thecybernetwork.net/httpdocs/server_root.php on line 2

Warning: include() [function.include]: Unable to access /httpdocs/header.php in /var/www/vhosts/thecybernetwork.net/httpdocs/server_root.php on line 2

Warning: include(/httpdocs/header.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/thecybernetwork.net/httpdocs/server_root.php on line 2

Warning: include() [function.include]: Failed opening '/httpdocs/header.php' for inclusion (include_path='.:') in /var/www/vhosts/thecybernetwork.net/httpdocs/server_root.php on line 2

Edit: I read your edit. Thanks for your help.
 
without access to your file structure there isnt a lot to do...

Where does this file sit on your server? the / might even be taking you all the way back to the root of your hard drive depending on how PHP was setup.

in which case you should use something like
/var/www/vhosts/thecybernetwork.net/httpdocs/

it just has to do with locating the file in the file structure tree


EDIT:
is there any reason you are adding the slash?
If you want to get to the directory above where you are include('../page.php'); take you to the directory above where the current file is.
 
Thank you! That works. There is still one problem though.
The following code doesn't work. It is because of the first slash... (again).
<img id="nav_nav" src="/images/navigation/nav.jpg" alt=""/>

Also, the reason I am doing this is that this code goes in a template that will be used in both the document root AND subfolders. The template code doesn't change, so I need code that will work in whatever folder it is put in.
 
:p
I feel really stupid right now. I forgot to upload the images folder... Thanks for all of your help. You're a lifesaver!
 
haha, happens to the best of us! ;)
Try editing a CSS file to fix this little annoyance, then after 240 reloads and line changes you remember that you never uploaded the new file to begin with! haha


You're very welcome.
 
Just to throw it out there, here is how I access the site root:
PHP:
include $_SERVER['DOCUMENT_ROOT']."/index.html";
 
Ok, I have another issue. I'm am also integrating phpBB's user database into my site. So, here is the code to do that. It also uses includes, so I used the above method to fix it. It works like a charm, but it has one small flaw.

Code to include phpBB.
PHP:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '/var/www/vhosts/thecybernetwork.net/httpdocs/forums/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup(); 
global $user;
?>

Flaw:
PHP:
<?php
							if($user->data['is_registered'])
							{
								echo "<br /><div class=\"center\">";
								echo get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']);
								echo "<br /><br />Welcome back " . $user->data['username'] .  " (<a href=\"" . append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=logout", true, $user->session_id). "\">Log out</a>)";
								echo "<br />You have <a href=\"" . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox') . "\">" . $user->data['user_new_privmsg'] . "</a> new private messages.";
								echo "</div><br />";
							}
							
							else and so on and so forth
When you try to log out using the above code, it makes the log out link is this:
HTML:
http://www.thecybernetwork.net/var/www/vhosts/thecybernetwork.net/httpdocs/forums/ucp.php?mode=logout&sid=4f453ccb0048f490d856b87b4e92afc3

EDIT: Just realized something. The phpBB code is called before the HTML tag. That may be what my problem is.

Not quite what I need, since thecybernetwork.net is the root. Thanks in advance.

MegaMan1311
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.