zenigame Posted January 6, 2008 Share Posted January 6, 2008 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 https://forums.phpfreaks.com/topic/84770-solved-php-include-variables-not-displaying/ Share on other sites More sharing options...
glenelkins Posted January 6, 2008 Share Posted January 6, 2008 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 https://forums.phpfreaks.com/topic/84770-solved-php-include-variables-not-displaying/#findComment-432006 Share on other sites More sharing options...
zenigame Posted January 6, 2008 Author Share Posted January 6, 2008 Hmm, still no good. I changed my line 19 to include_once ( "$_GET .html" ); but get a similar error. I have the html files in the same directory as template.php too. *ignore the above Thanks glen, that works perfectly! Link to comment https://forums.phpfreaks.com/topic/84770-solved-php-include-variables-not-displaying/#findComment-432007 Share on other sites More sharing options...
revraz Posted January 6, 2008 Share Posted January 6, 2008 How is $page defined? Link to comment https://forums.phpfreaks.com/topic/84770-solved-php-include-variables-not-displaying/#findComment-432012 Share on other sites More sharing options...
zenigame Posted January 6, 2008 Author Share Posted January 6, 2008 Oh wait, now it works! After trying what glen suggested I didn't define the var in the url. Thank you thank you thank you! Link to comment https://forums.phpfreaks.com/topic/84770-solved-php-include-variables-not-displaying/#findComment-432015 Share on other sites More sharing options...
glenelkins Posted January 6, 2008 Share Posted January 6, 2008 no worries Link to comment https://forums.phpfreaks.com/topic/84770-solved-php-include-variables-not-displaying/#findComment-432025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.