WarDeities Posted March 7, 2008 Share Posted March 7, 2008 heres what I am trying to do: if(isset($_GET['page'])) { $page=$_GET['page']; $page=strip_tags($page); print"<div id='content'>"; print"$page.php<br>"; include '$page.php'; print"</p></td></tr> </div>"; } when I get page addnews from this code on same page: <a href='index.php?page=addnews'> I get this error: Warning: main(/$page.php) [function.main]: failed to open stream: No such file or directory in /index.php on line 56 I see it is not taking the vaiable (in this case addnews)...can you use vaiables in include statments??? If so please tell me how! Thanks Link to comment https://forums.phpfreaks.com/topic/94820-uhhhelp-pleasewith-include-and-variables/ Share on other sites More sharing options...
JasonO Posted March 7, 2008 Share Posted March 7, 2008 Take away the ' ' around the news.php variable. Putting ' ' around it makes the variable become a text string, and will actually look for $news.php, instead of the variable value itself. Link to comment https://forums.phpfreaks.com/topic/94820-uhhhelp-pleasewith-include-and-variables/#findComment-485635 Share on other sites More sharing options...
WarDeities Posted March 7, 2008 Author Share Posted March 7, 2008 ...thanks...1 new problem now.... :'( This error Warning: main(addnewsphp) [function.main]: failed to open stream: No such file or directory in /index.php on line 56 Now it is not recoginizing the "." (period) any suggestions now... ? Link to comment https://forums.phpfreaks.com/topic/94820-uhhhelp-pleasewith-include-and-variables/#findComment-485637 Share on other sites More sharing options...
notanoob Posted March 7, 2008 Share Posted March 7, 2008 include $page . '.php'; Link to comment https://forums.phpfreaks.com/topic/94820-uhhhelp-pleasewith-include-and-variables/#findComment-485639 Share on other sites More sharing options...
WarDeities Posted March 7, 2008 Author Share Posted March 7, 2008 awesome ass hell....works perfect... THANKS!!! Link to comment https://forums.phpfreaks.com/topic/94820-uhhhelp-pleasewith-include-and-variables/#findComment-485648 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.