albasel Posted August 7, 2008 Share Posted August 7, 2008 Hello every body here I have a folder contain more than 6oo htm pages and I want to call them in one php file I have this code working fine but this time failed to show the htm files. This is the php code <?php if (!isset($_GET['p'])) { // If no page is chosen load this page include("pages/main.htm"); } else{ $filename="pages/" . $_GET['p'] . ".htm"; if (file_exists($filename)){ include("pages/" . $_GET['p'] . ".htm"); } else{ include("pages/error.htm"); } } ?> I usually link to display htm pages as follow example index.php?p=100 and the htm page 100 from the the directory will be called and displayed I do not why this time it is not working with me please i need help ASA or some one do for me new php code Quote Link to comment Share on other sites More sharing options...
deadlyp99 Posted August 7, 2008 Share Posted August 7, 2008 What error are you getting? Are the pages you are trying to show html files, or just file with no extension? Because that could be the problem if it is trying to show "/pages/100.htm.htm", and it doesn't exist. Also please refrain from all caps thread titles Quote Link to comment Share on other sites More sharing options...
papaface Posted August 7, 2008 Share Posted August 7, 2008 Not sure what is wrong but: $filename="pages/" . $_GET['p'] . ".htm"; if (file_exists($filename)){ include("pages/" . $_GET['p'] . ".htm"); Is pointless excess code. Should be: $filename="pages/" . $_GET['p'] . ".htm"; if (file_exists($filename)){ include($filename); Quote Link to comment Share on other sites More sharing options...
albasel Posted August 7, 2008 Author Share Posted August 7, 2008 Thanks for ur replay Im waiting for help The error i got like no page in the server with this name 404 error Quote Link to comment Share on other sites More sharing options...
deadlyp99 Posted August 7, 2008 Share Posted August 7, 2008 Give us some of the file names you are working with in the /pages/ directory please. Quote Link to comment Share on other sites More sharing options...
albasel Posted August 7, 2008 Author Share Posted August 7, 2008 Thanks for the help I will try this right now $filename="pages/" . $_GET['p'] . ".htm"; if (file_exists($filename)){ include($filename); Quote Link to comment Share on other sites More sharing options...
deadlyp99 Posted August 7, 2008 Share Posted August 7, 2008 That isn't going to help you. All it will do is reduce the code size making it shorter, its the same code, just with better use of a variable. How about you let me know what this does: $filename="./pages/" . $_GET['p'] . ".html"; if (file_exists($filename)){ include($filename); Quote Link to comment Share on other sites More sharing options...
albasel Posted August 7, 2008 Author Share Posted August 7, 2008 I have try this also those not work $filename="./pages/" . $_GET['p'] . ".html"; if (file_exists($filename)){ include($filename); DIR name is pages Incloude 650 htm pages i have index php file not in the same DIR beside the pages DIR i want to call the htm pages in the from the pages DIR plz Quote Link to comment Share on other sites More sharing options...
papaface Posted August 7, 2008 Share Posted August 7, 2008 Can you tell us the directory structure please. i.e. where is your index file in relation to the pages folder. Quote Link to comment Share on other sites More sharing options...
albasel Posted August 7, 2008 Author Share Posted August 7, 2008 Ok I have the main DIR named shaer inside this DIR the php index file and the pages DIR the pages DIR contain the htm pages Quote Link to comment Share on other sites More sharing options...
deadlyp99 Posted August 7, 2008 Share Posted August 7, 2008 Do a quick echo of $_GET['p']; to make sure it is even holding a proper variable.... Let us know. Quote Link to comment Share on other sites More sharing options...
albasel Posted August 7, 2008 Author Share Posted August 7, 2008 yes all the links to 650 pages i did like this index.php?p=1 index.php?p=2 index.php?p=3 and so on Quote Link to comment Share on other sites More sharing options...
abdfahim Posted August 7, 2008 Share Posted August 7, 2008 can you just print the following line echo "./pages/" . $_GET['p'] . ".html"; and then copy the printed path and paste it to your browser address bar to see whether it could load the file seperately. Quote Link to comment Share on other sites More sharing options...
albasel Posted August 7, 2008 Author Share Posted August 7, 2008 I really do not know what u mean i have did test file and put this code <?php echo "./pages/" . $_GET['p'] . ".html"; ?> and i call the test file but the output is ./pages/.html in the browser Quote Link to comment Share on other sites More sharing options...
deadlyp99 Posted August 7, 2008 Share Posted August 7, 2008 you want to do this for your url. Assuming a local server, and the file is index.php: 127.0.0.1/index.php?p=100 Quote Link to comment Share on other sites More sharing options...
albasel Posted August 7, 2008 Author Share Posted August 7, 2008 Yes this is right..............127.0.0.1/index.php?p=100 but it is not working with me when i have upload the files Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.