...

View Full Version : PHP include no longer works?



cooly291
12-30-2006, 09:48 PM
A while back, I used to use the:

<?php include("$id.html"); ?>

for my site, but then I stopped for a while. Now, I come back to use it, and it doesn't work.

I put this "<?php include("$id.html"); ?>" where my content normally goes in "main.php" and then I go to "site.com/main.php?id=content" (where content is an HTML), but I get an error that says:




Warning: main(.html) [function.main]: failed to open stream: No such file or directory in /home/animegal/public_html/nosuchthing/newlayout/main.php on line 74

Warning: main(.html) [function.main]: failed to open stream: No such file or directory in /home/animegal/public_html/nosuchthing/newlayout/main.php on line 74

Warning: main() [function.include]: Failed opening '.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/animegal/public_html/nosuchthing/newlayout/main.php on line 74


am I doing something wrong? this used to work - that's why I think that it's me doing something wrong...

Any suggestions?

croatiankid
12-30-2006, 10:00 PM
get rid of the $, they're only for variables.

cooly291
12-30-2006, 11:14 PM
You mean out of the original code? So it would be:

<?php include("id.html"); ?>

that didn't work

Metroid48
12-30-2006, 11:18 PM
Couldn't you use fopen?

As in:

<?php
$fname = "id.html";
$fr = fopen($fname, 'r');
$Result = fread($fr, filesize($fname));
fclose($fr);
echo $Result;
?>

Keep the $ if it's inside a string and the filename has it.

cooly291
12-30-2006, 11:24 PM
do I need to change something in that code, or just paste it where I need the content to show up?

firepages
12-31-2006, 12:07 AM
looks like register_globals has been turned off... use


<?php include("{$_GET['id']}.html"); ?>

cooly291
12-31-2006, 12:10 AM
Great! That worked!

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum