How to GetPage - why does this cause so many errors?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How to GetPage - why does this cause so many errors?

Post by simonmlewis »

Code: Select all

$page = $_GET['page'];
if ($page == "") { }
else
{
function getPage()
{
 $thispage="includes/".$_GET['page'].".inc";
 include $thispage;
}  
} 

$menu = $_GET['menu'];
if ($menu == "") {}
else
{
function getMenu()
{
$thismenu="includes/menu/".$_GET['menu'].".inc";
include $thismenu;
}
}
[text]
[26-Mar-2012 20:47:21] PHP Warning: include(includes/undefined.inc) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/domain/public_html/index.php on line 110
[26-Mar-2012 21:01:09] PHP Warning: include(includes/menu/ho.inc) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/domain/public_html/index.php on line 121
[/text]

The 110 and 121 are include $thispage and include $thismenu.

Why would it cause these errors like thousands of times?? And is there anything I shoudl ask our hosts; ie. is it down to apache version?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
azycraze
Forum Commoner
Posts: 56
Joined: Mon Oct 24, 2011 12:08 pm
Location: India

Re: How to GetPage - why does this cause so many errors?

Post by azycraze »

your variable $page is not set.
please post more code and your folder structure.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: How to GetPage - why does this cause so many errors?

Post by social_experiment »

simonmlewis wrote:Why would it cause these errors like thousands of times??
Are all the errors created on one execution of the script
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How to GetPage - why does this cause so many errors?

Post by simonmlewis »

Azxycraze was correct, just noticed myself too.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply