Web Hosting Talk







View Full Version : PHP include not working?


AaronN322
02-10-2003, 07:48 PM
ok...I am using an inline frame here...and a simple include script on the index.... http://www.centralbaptistcanton.com/new/test/index.cbc when I click "contact us" it should go to contact but it isn't..... this is the code i am using

<?
$page = $_GET['page'];
if (!$page) {
include("main.htm");
} else {
if (file_exists($page.".htm")) {
include($page.".htm");
} else {
include("error.htm");
}
}
?>

michaeln
02-10-2003, 11:24 PM
Strange problem you have there.

luxline
02-11-2003, 02:22 AM
Script is fine. Works 100%, try calling it index.php OR change the first line to
<?php

Dont know how your server is setup to handle .cbc files.

michaeln
02-11-2003, 09:01 AM
Apparantly he did add the cbc file to .htaccess or httpd.conf to be parsed by php as the code isn't getting patched through and it is showing his main page in the center section. However like you said his code works fine on my server. Strange problem.

However I would do as luxline suggests and try changing the name. Shouldn't matter if the current file is being parsed but you never know.

Also change
$page = $_GET['page'];
to
$page = $_GET['page'];
echo $_GET['page'];

Just for fun to see if the problem is there.

AaronN322
02-11-2003, 05:29 PM
ok, I tried all of the ideas.... "<?php" ,
"$page = $_GET['page'];
echo $_GET['page'];"
all on the .php, and .cbc but it dont work! Is it possibly because the links are coming from an inline frame? ifso, how could I fix that, while keeping the frame?

-Aaron

michaeln
02-11-2003, 06:24 PM
the iframe shouldn't effect that.

The reason I asked you to put echo $_GET['page'] was to see if it output the value of page that you sent. Did it?

Michael

AaronN322
02-11-2003, 07:29 PM
michaeln,

where would I see that output?

michaeln
02-11-2003, 10:52 PM
Right about the content it spits out...

where the code is. Is it still there?

Michael

michaeln
02-12-2003, 01:54 PM
AaronN322,

I want to see something. Make a new php file and put this in it:
<?php
phpinfo();
?>

Let us know where that page is...

FiRe-AnGeL
02-12-2003, 02:42 PM
AaronN322,

The script is absolutely correct, but it's not being interpreted as php...

If the rest of the ppl reminded to check the source of the page they would see:

<base target="_self">
<?
$page = $_GET['page'];
if (!$page) {
echo('main.htm');
} else {
echo($page.'.htm');
}
?>
</head>

and now everyone knows what the problem is :)

But it was suposed initially that you already did something like this:

Create a file in you www root named: .htaccess
Inside it, write:

AddType application/x-httpd-php .cbc


Everything should be fine now :)
Good luck & if you need anything don't hesitate to ask ;)

michaeln
02-12-2003, 02:54 PM
FiRe-AnGeL

It appears that php code is something he put there as a test. I did notice it but if you look more carefully you will see that is not the code he has in his first post.

There he has echo statements to print the value of the variable to (what I assume) is to check if the variables are working. Ofcoarse that never worked because he is in a htm file.

The script he is speaking of (I assume) is in the index.cpc page where it should be. What you quoted there is on the menu.htm page. At least that is what I have found. I didn't see any page on the index.cbc page and it is showing the main page in the center section so I can only assume that it works.


AaronN322,

I you would like me to log into your server via FTP and look at it more closely to verify all of this that I just said and try and fix the problem you can PM me.

Michael

luxline
02-12-2003, 02:59 PM
Europeans are
....as clean as the French
....as controlled as the Italians
....as sober as the Irish
.....
....as technical as the Portuguese.

Well done FiReAnGeL. God, who ever uses <base> anymore, thought that went away with netscape 2.

This one had me baffled.

michaeln
02-12-2003, 03:06 PM
Strangly the person is using <base>

However if you look down:
further their links inclue target="_top"

<a target="_top" href="index.cbc?page=contact">Contact us</a>

So the base call isn't the problem. Neither is that php. There has to be something else.

FiRe-AnGeL
02-12-2003, 03:14 PM
Yup, didn't notice the include/echo change ...

And i thought he was going to use the whole site in php... my mistake, I have .htm and .html using php too ... so ... :stickout:
but either way, I'd rather create the whole page dyn and use tables instead of framing it

(btw luxline, try giving 5-min-help without the source and guess something too :D)

michaeln
02-12-2003, 03:41 PM
Yes, personally I would have included the menu with a php include rather than a iframe. But it is his site so he can do it however he wants.

ub3r
02-12-2003, 05:28 PM
try calling it with


<?php virtual(); ?>


That's my best guess, sorry :(