File does not get included

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
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

File does not get included

Post by amir »

Hello,

I am working a project and this has different categories e.g. Development, Design, Hosting etc. I am using a main index.php on root and all the categories on the same folder where I have this main index.php. When a user clicks on any category, it calls index.php of that category. For example, if user clicks on a link/category hosting, it calls the index.php of that category. Its working fine for all other categories except one. Can anybody please give any idea why this is happening because these are on same level and I dont find any unusual thing in it.

TIA!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Use require() instead of include() , set error_reporting and display_errors to appropriate debug settings and print important variables/parameters just before decision are made depending on their values.
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post by amir »

Thanks Volka!

I am using 'switch' for it. If query string has 'domain', display file of it, if query string has 'hosting', display file of it and so on. If no matches then display the default. After playing a bit with it, I just have come to know that switch does not display not only if there is no match but also if the matching file has some errors or warnings. Does it make any sense?

Please advise!

Thanks once again.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

amir wrote:I just have come to know that switch does not display not only if there is no match but also if the matching file has some errors or warnings. Does it make any sense?
Honestly? No.
I guess you forgot to use break at the end of each case block and the other files have a die/exit statement somewhere in them.

Code: Select all

switch($yadda) {
	case 'abc':
		require 'abc/index.php';
		break;
	case 'xyz':
		require 'shalalalalu/index.php';
		break;
	default:
		require 'error.php';
		break;
}
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post by amir »

I am using break in switch statement but I am not sure about CCS files as these are encrypted.

Thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Then this shouldn't happen. But I cannot tell you where the error is from the information you've provided.
Post Reply