PlagueInfected Posted July 27, 2009 Share Posted July 27, 2009 I'm still very new to php, this is what I'm trying to do. on my website http://plagueinfected.com/?pg=portfolio I'm trying to call an include from another page to appear below my portfolio images. The url I try to use is http://plagueinfected.com/?pg=portfolio&design=stateoftheunion I have 3 pages in use with this portpage.php, portfoliopage.php, and stateoftheunion.php portpage.php has this code <?php $sub_path = getcwd() . '/portfolio'; // Wherever you keep the page files $sub_extension = '.php'; // .php do not change $sub_default = 'stateoftheunion'; // Page shown by default (filename not url) no need for an array since this script reads all the pages in the directory function show_error($msg) { echo "<h1>Error</h1>\n"; echo "<span>" . $msg . "</span>\n"; } function sub_include() { global $sub_path, $sub_extension, $sub_default; $sub_filename = isset($_GET['design']) ? $_GET['design'] : $sub_default; if (! $sub_filename) { show_error('No page selected.'); return; } foreach (array('.', '/', '\\') as $sub_illegal) { if (false !== strpos($sub_filename, $sub_illegal)) { show_error('Illegal characters in page parameter.'); return; } } $sub_fullpath = realpath(sprintf('%s/%s.%s', $sub_path, $sub_filename, $sub_extension)); if (! file_exists($sub_fullpath)) { show_error('This page has not been created yet.'); return; } include($sub_fullpath); } ?> portfoliopage.php has a code to require once the portpage script on it <?php require_once ('http://plagueinfected.com/inc/portpage.php'); ?> than on the portfolio page also where I want my images to appear my friend told me to insert this code <?php sub_file(); ?> when the sub_file script is on i get a fatal error, however when i take it off it's gone but the link wont work correctly. im lost in this situation and dont know what options i have after this....any ideas Link to comment https://forums.phpfreaks.com/topic/167685-stringing-a-url/ Share on other sites More sharing options...
darkfreaks Posted July 28, 2009 Share Posted July 28, 2009 where is function sub_file defined Link to comment https://forums.phpfreaks.com/topic/167685-stringing-a-url/#findComment-884401 Share on other sites More sharing options...
darkfreaks Posted July 28, 2009 Share Posted July 28, 2009 formatted your code and putting it between bbcode code tags <?php // Wherever you keep the page files $sub_path = getcwd() . '/portfolio'; // .php do not change $sub_extension = '.php'; // Page shown by default (filename not url) no need for an array since this script reads all the pages in the directory $sub_default = 'stateoftheunion'; function show_error($msg) { echo "<h1>Error</h1>\n"; echo "<span>" . $msg . "</span>\n"; } function sub_include() { global $sub_path, $sub_extension, $sub_default; $sub_filename = isset($_GET['design']) ? $_GET['design'] : $sub_default; if (!$sub_filename) { show_error('No page selected.'); return; } foreach (array('.', '/', '\\') as $sub_illegal) { if (false !== strpos($sub_filename, $sub_illegal)) { show_error('Illegal characters in page parameter.'); return; } } $sub_fullpath = realpath(sprintf('%s/%s.%s', $sub_path, $sub_filename, $sub_extension)); if (!file_exists($sub_fullpath)) { show_error('This page has not been created yet.'); return; } include($sub_fullpath); } ?> Link to comment https://forums.phpfreaks.com/topic/167685-stringing-a-url/#findComment-884442 Share on other sites More sharing options...
darkfreaks Posted July 28, 2009 Share Posted July 28, 2009 unless of course you mean sub_include() Link to comment https://forums.phpfreaks.com/topic/167685-stringing-a-url/#findComment-884459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.