cpugeek Posted July 24, 2007 Share Posted July 24, 2007 I'm having a problem with my php inclusions.for some reason it doesn't work.I'm supposed to be able to access it @:http://127.0.0.1/index.php?x=PagenameI have 5 files total.Index.php, default.php.the other three are one, two, three.phphere's my code: <?php // Include content if (is_file("$x.php")) { include("$x.php"); } else { include("default.php"); // the default page } ?> can anyone help me?Any & All help is appreciated. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 24, 2007 Share Posted July 24, 2007 What's the problem? The syntax for include is correct, assuming $x has a value. Link to comment Share on other sites More sharing options...
cpugeek Posted July 24, 2007 Author Share Posted July 24, 2007 It just doesn't work.i go to: http://127.0.0.1/index.php?x=one& it just displays the default. Link to comment Share on other sites More sharing options...
cpugeek Posted July 24, 2007 Author Share Posted July 24, 2007 Anyone know what the problem is? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 24, 2007 Share Posted July 24, 2007 If that is the exact code up there, you need to get x from $_GET first. Link to comment Share on other sites More sharing options...
zppblood Posted July 24, 2007 Share Posted July 24, 2007 Could be what justsomeguy said, make sure $x has a value in your code. <?php $x=basename($_GET['x']); $allow=array('index', 'default', 'one', 'two', 'three'); // Take out whatever files you want, or add more if (file_exists("$x.php") && in_array($x, $allow)) { include("$x.php"); } else { include("default.php"); }?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.