Jump to content

Including problem


Shade.Alchemist

Recommended Posts

Thanks for that, fixed the unexpected variable problem, but I still have this in the main page :( :

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 160

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 160

 

Warning: main(): Failed opening '.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eternalt/public_html/index.php on line 160

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 164

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 164

 

Warning: main(): Failed opening '.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eternalt/public_html/index.php on line 164

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 168

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 168

 

Warning: main(): Failed opening '.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eternalt/public_html/index.php on line 168

 

160: include("$id.php");

 

164: include ($id . '.php');

 

168: include ($_GET['id'] . '.php');

Link to comment
Share on other sites

The this is, even when viewing the index.php I'm getting the error:

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 160

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 160

 

Warning: main(): Failed opening '.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eternalt/public_html/index.php on line 160

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 164

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 164

 

Warning: main(): Failed opening '.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eternalt/public_html/index.php on line 164

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 168

 

Warning: main(.php): failed to open stream: No such file or directory in /home/eternalt/public_html/index.php on line 168

 

Warning: main(): Failed opening '.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eternalt/public_html/index.php on line 168

Link to comment
Share on other sites

You seriously need to learn how to debug man. Especially since all of this can easily be debugged really. Especially if you would post the full code, the file that is including the file and the file to be included.

 

Because that that main is stating is that there is no file just named ".php" The variable is not being displayed. So somewhere in your code you are either wiping out that variable or not setting it properly. Whether it be you are setting it in a function and forgot to return or do the global scape or you have register_globals turned off and you think it is on.

 

Syntax errors are confusing in any language a basic rule of thumb is if the error is not in the line it states chances are it is somewhere above it. I learned that my first day of programming. Syntax errors are the easiest to fix and it really makes me think if people should be trying to code who cannot even fix their own syntax errors.

 

Anyone until you post FULL CODE of the file involved you will NOT get this problem resolved. Pandoras box would take a long time to open by luck.

Link to comment
Share on other sites

Was playing around with the code and things seem to work now...

I'll post the code in case some of you guys are just curious.

 

<HTML>
<HEAD><link href="style2.css" rel="stylesheet" type="text/css">
<TITLE>Eternal Tales</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<div align="center">
<TABLE WIDTH=800 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
	<TD background="images/ETv2_01.png" WIDTH=67 HEIGHT=51 ALT=""><a href="/"><img src="images/ETv2_01.png"></a></TD>

	<TD class="talesnews"background="images/ETv2_02.png" WIDTH=68 HEIGHT=51 ALT=""><a href="http://www.divine-infinity.com/forums/"><img src="images/ETv2_02.png"></a></TD>

	<TD background="images/ETv2_03.png" WIDTH=58 HEIGHT=51 ALT=""><a href="?id=content/tales.php"><img src="images/ETv2_03.png"></a></TD>

	<TD COLSPAN=3 background="images/ETv2_04.png" WIDTH=96 HEIGHT=51 ALT="">
<a href="link"><img src="images/Contactbutton.png"></a></TD>

	<TD COLSPAN=10 background="images/ETv2_05.png" WIDTH=511 HEIGHT=51 ALT=""></TD>

</TR>
<TR>
	<TD COLSPAN=16 background="images/ETv2_06.png" WIDTH=800 HEIGHT=68 ALT=""></TD>
</TR>
<TR>
	<TD COLSPAN=10 ROWSPAN=6 background="images/ETv2_07.png"
	 WIDTH=563 HEIGHT=156 ALT=""></TD>

	<TD COLSPAN=4 class="talesnews" background="images/ETv2_08.png"
	 WIDTH=225 HEIGHT=26 ALT="">
	- <a href="link"> The Truth Is Right Here </a>

	</TD>

	<TD COLSPAN=2 ROWSPAN=6 background="images/ETv2_09.png" WIDTH=12 HEIGHT=156 ALT=""></TD>

</TR>
<TR>
	<TD COLSPAN=4 class="talesnews" background="images/ETv2_10.png"
	 WIDTH=225 HEIGHT=26 ALT="">
	- <a href="link"> The Truth Is Right Here </a>

	</TD>
</TR>
<TR>
	<TD COLSPAN=4 class="talesnews" background="images/ETv2_11.png"
	 WIDTH=225 HEIGHT=26 ALT="">
	- <a href="link"> The Truth Is Right Here </a> 

	</TD>
</TR>
<TR>
	<TD COLSPAN=4 class="talesnews" background="images/ETv2_12.png"
	 WIDTH=225 HEIGHT=26 ALT="">
	- <a href="link"> The Truth Is Right Here </a>

	</TD>
</TR>
<TR>
	<TD COLSPAN=4 class="talesnews" background="images/ETv2_13.png"
	 WIDTH=225 HEIGHT=26 ALT="">
	- <a href="link"> The Truth Is Right Here </a>

	</TD>
</TR>
<TR>
	<TD COLSPAN=4 class="talesnews" background="images/ETv2_14.png"
	 WIDTH=225 HEIGHT=26 ALT="">
	- <a href="link"> The Truth Is Right Here </a>

	</TD>
</TR>
<TR>
	<TD COLSPAN=16 background="images/ETv2_15.png" WIDTH=800 HEIGHT=16 ALT=""></TD>
</TR>
<TR>
	<TD COLSPAN=16 class="affiliate" background="images/ETv2_16.png"
	 WIDTH=800 HEIGHT=25 ALT="">

<?php 

include('Edit-WebAff.php'); 

?>

	</TD>
</TR>
<TR>
	<TD COLSPAN=16 background="images/ETv2_17.png" WIDTH=800 HEIGHT=28 ALT=""></TD>
</TR>
<TR>
	<TD COLSPAN=4 ROWSPAN=7 class="nav" valign="top" background="images/ETv2_18.png"
	 WIDTH=258 HEIGHT=357 ALT="">

<?php 

include('Edit-Navigation.php'); 

?>

</TD>

	<TD ROWSPAN=7 background="images/ETv2_19.png" WIDTH=3 HEIGHT=357 ALT=""></TD>

	<TD COLSPAN=11 background="images/ETv2_20.png" WIDTH=539 HEIGHT=3 ALT=""></TD>

</TR>
<TR>
	<TD COLSPAN=2 background="images/ETv2_21.png" WIDTH=45 HEIGHT=44 ALT=""></TD>

	<TD background="images/ETv2_22.png" WIDTH=151 HEIGHT=44 ALT=""></TD>

	<TD background="images/ETv2_23.png" WIDTH=1 HEIGHT=44 ALT=""></TD>

	<TD COLSPAN=2 background="images/ETv2_24.png" WIDTH=151 HEIGHT=44 ALT=""></TD>

	<TD background="images/ETv2_25.png" WIDTH=1 HEIGHT=44 ALT=""></TD>

	<TD background="images/ETv2_26.png" WIDTH=151 HEIGHT=44 ALT=""></TD>

	<TD COLSPAN=2 background="images/ETv2_27.png" WIDTH=37 HEIGHT=44 ALT=""></TD>

	<TD ROWSPAN=7 background="images/ETv2_28.png" WIDTH=2 HEIGHT=395 ALT=""></TD>

</TR>
<TR>
	<TD COLSPAN=2 ROWSPAN=3 background="images/ETv2_29.png" WIDTH=45 HEIGHT=89 ALT=""></TD>

	<TD COLSPAN=6 background="images/ETv2_30.png" WIDTH=455 HEIGHT=3 ALT=""></TD>

	<TD COLSPAN=2 ROWSPAN=3 background="images/ETv2_31.png" WIDTH=37 HEIGHT=89 ALT=""></TD>

</TR>
<TR>
	<TD> <a href="link"><img src="images/ETv2_32.png"
	 WIDTH=151 HEIGHT=83 ALT="" border="no"></a></TD>

	<TD background="images/ETv2_33.png" WIDTH=1 HEIGHT=83 ALT=""></TD>

	<TD COLSPAN=2> <a href="link"><img src="images/ETv2_34.png"
	 WIDTH=151 HEIGHT=83 ALT="" border="no"></a></TD>

	<TD background="images/ETv2_35.png" WIDTH=1 HEIGHT=83 ALT=""></TD>

	<TD> <a href="link"><img src="images/ETv2_36.png"
	 WIDTH=151 HEIGHT=83 ALT="" border="no"></a></TD>

</TR>
<TR>
	<TD COLSPAN=6 background="images/ETv2_37.png" WIDTH=455 HEIGHT=3 ALT=""></TD>
</TR>
<TR>
	<TD COLSPAN=10 background="images/ETv2_38.png" WIDTH=537 HEIGHT=44 ALT=""></TD>
</TR>
<TR>
	<TD COLSPAN=10 class="content" valign="top" background="images/ETv2_39.png"
	 WIDTH=537 HEIGHT=177 ALT="">

<?php
$include = "home.php";
$id = $_GET['id'];
$show = $_GET['show'];
if (isset($id)) { 
if ($id == "content") { $include = "$id/$show.php"; }
}
if (!file_exists($include)) { $include = "404.php"; }
require_once($include);
?>

	</TD>
</TR>
<TR>
	<TD COLSPAN=15 background="images/ETv2_40.png"
	 WIDTH=798 HEIGHT=41 ALT="">
	</TD>
</TR>
<TR>
	<TD COLSPAN=16 background="images/ETv2_41.png" WIDTH=800 HEIGHT=10 ALT=""></TD>
</TR>
<TR>
	<TD COLSPAN=16 class="footer" background="images/ETv2_42.png"
	 WIDTH=800 HEIGHT=48 ALT="">
<?php 

include('Edit-Footer.php'); 

?>

	</TD>
</TR>
<TR>
	<TD background="images/spacer.gif" WIDTH=67 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=68 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=58 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=65 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=3 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=28 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=17 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=151 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=105 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=46 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=151 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=27 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=10 HEIGHT=1 ALT=""></TD>
	<TD background="images/spacer.gif" WIDTH=2 HEIGHT=1 ALT=""></TD>
</TR>
</TABLE>
</div>
</BODY>
</HTML>

 

Thanks for the help everybody, I appreciate it alot :)

 

Just one thing...

 

?id=content/staff&show=tenks

This doesn't seem to show the intended file, where as the one below does...

?id=content&show=crew

 

How do you fix it? I'm pretty sure I've just misplaced something in the first one.

Link to comment
Share on other sites

You will never get that to work =)

?id=content/staff&show=tenks

 

you cant separate folders with / in the url

 

you have to do something like this

?id=content&cat=staff&show=tenks

 

and then you must do something like this where you include the wanted file

<?php
if ($id == "content") { $include = "$id/$cat/$show.php"; }
?>

 

I also have another good idea for you... visit this website www.php.net and read about functions and how to use them

Link to comment
Share on other sites

I replaced

<?php
$include = "home.php";
$id = $_GET['id'];
$show = $_GET['show'];
if (isset($id)) { 
if ($id == "content") { $include = "$id/$show.php"; }
}
if (!file_exists($include)) { $include = "404.php"; }
require_once($include);
?>

With

<?php
$include = "home.php";
$id = $_GET['id'];
$show = $_GET['show'];
if ($id == "content") { $include = "$id/$cat/$show.php"; }
if (isset($id)) { 
if ($id == "content") { $include = "$id/$show.php"; }
}
if (!file_exists($include)) { $include = "404.php"; }
require_once($include);
?>

 

Yet now I get page not found even though the the file is in the specified directory :S

Link to comment
Share on other sites

first of all... you have forgot to add

$cat = $_GET['cat'];

 

second.. you cant setup the code like you've done..  more like this

if (isset($id)) {
if (isset($cat)) { $include = "$id/$cat/$show.php"; }
}

 

but i really cant give you any more good help here.. cuz I have no clue at all on how your map/file tree looks like.. i understand that tenks.php is located under content/staff.. but that's all i know... I think you should start out much slower than you're doing now... go step by step, dont try to build everything at once...

 

i have a test folder on my server.. and everytime I'm trying out new stuff I try it there before I add it to the site...

Link to comment
Share on other sites

I don't think I'm going to fast... I've got all the info and content, I just need to get the inclusion working. I obviously don't have the knowledge to do this however, I'm reading into php but I cannot find a solution as I am still pretty new to the whole concept. Sorry if I'm not very helpful...

 

So anyway, I still have it appearing to not find the files... and how much of the file tree do you need to know? I'll give what I think you might need... Just ask if you need more.

 

>content

-games

-media

-profiles

-staff

>images

>media

 

The inclusion code at the moment is this

<?php
$include = "home.php";
$id = $_GET['id'];
$cat = $_GET['cat'];
$show = $_GET['show'];
if (isset($id)) {
if (isset($cat)) { $include = "$id/$cat/$show.php"; }
}
if ($id == "content") { $include = "$id/$show.php"; }
if (!file_exists($include)) { $include = "404.php"; }
require_once($include);
?>

Link to comment
Share on other sites

if the index.php is outside content and games, media, profiles & staff are sub folders i would maybe do something like this:

 

<?php

$include = "home.php";
$show = $_GET['show'];
$cat = $_GET['cat'];
$sub = $_GET['sub'];

if (isset($id)) {
	if (isset($cat)) {
		if (isset($sub)) { $include = "$cat/$sub/$show.php"; }
		else { $include = "$cat/$show.php"; }
	} else { $include = "$show.php"; }
}
if (!file_exists($include)) { $include = "404.php"; }
require_once($include);

?>

 

here's an explination on what each variable means:

 

$show - This is used to get file names

$cat - this is used to access the first folder

$sub - this is used to access subfolder inside $cat

 

so if you want to access a file under content/staff

the link should be

?cat=content&sub=staff&show=filename

 

if you want to access a file inside content this would be the link

?cat=content&show=filename

 

but if you want to access a file in the same folder as index.php you use

?show=filename

 

hope this helped a little

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.