RSmiroldo Posted March 12, 2008 Share Posted March 12, 2008 I'am trying to use this code <?php include("$id.txt"); ?> to generate content in the certain point in my layout so i can simply link to .txt files in the address bar so they appear in that portion of the layout but I'am currently getting the error Warning: main(.txt): failed to open stream: No such file or directory in /home/content/i/w/s/iwsports/html/index2.php on line 302 I'am so confused any suggestions? Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/ Share on other sites More sharing options...
Northern Flame Posted March 12, 2008 Share Posted March 12, 2008 are you sure $id was set correctly? Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490171 Share on other sites More sharing options...
RSmiroldo Posted March 12, 2008 Author Share Posted March 12, 2008 Im not exactly sure how would i know? Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490197 Share on other sites More sharing options...
Northern Flame Posted March 12, 2008 Share Posted March 12, 2008 well did u set $id Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490250 Share on other sites More sharing options...
awpti Posted March 12, 2008 Share Posted March 12, 2008 if($id != "") { include("{$id}.txt"); } There you go. Enjoy. Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490260 Share on other sites More sharing options...
PC Nerd Posted March 12, 2008 Share Posted March 12, 2008 also: include($id.".txt"); that also works. Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490264 Share on other sites More sharing options...
RSmiroldo Posted March 12, 2008 Author Share Posted March 12, 2008 awpi i put it in just like that and it eliminated the error would i simply link it like this now http://www.islandwidesports.com/index2.php?id=test when i do that nothing comes up.. Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490402 Share on other sites More sharing options...
RSmiroldo Posted March 12, 2008 Author Share Posted March 12, 2008 and also PC nerd i tried putting in <?iphp include($id.".txt"); ?> and it resulted in the same error. Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490421 Share on other sites More sharing options...
trq Posted March 12, 2008 Share Posted March 12, 2008 Use... <?php if (isset($_GET['id'])) { if (file_exists($_GET['id'] . '.txt')) { include $_GET['id'] . '.txt'; } } ?> Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490422 Share on other sites More sharing options...
RSmiroldo Posted March 12, 2008 Author Share Posted March 12, 2008 that worked thank you so very much Link to comment https://forums.phpfreaks.com/topic/95735-content-include-code/#findComment-490455 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.