Jump to content

[SOLVED] PHP Include variables not displaying


zenigame

Recommended Posts

Hello! I'm a new too php and have been trying to make a template solution for a website I'm working on.

I followed a tutorial, http://www.alistapart.com/stories/phpcms/ at alistapart and am developing locally with mamp on osx.

 

I receive these errors:

Notice: Undefined variable: page in /Applications/MAMP/htdocs/asb/template.php on line 19

 

Warning: include(.html) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/asb/template.php on line 19

 

Warning: include() [function.include]: Failed opening '.html' for inclusion (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/asb/template.php on line 19

 

------------------------

 

And my line 19 is:

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

 

I enter this as my url:

http://localhost:8888/asb/template.php?page=home

 

Home doesn't display through the template. Any idea what's wrong?

 

Link to comment
Share on other sites


do you have $page  set from $_GET['page'] ??

 

try this:

 

<?php

 

include_once ( "$_GET


.html" );

 

?>

 

If that works then your $page variable doesnt contain the correct  data which is actually indicated by this error: Warning: include(NO_FILE_NAME_HERE.html) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/asb/template.php on line 19

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.