• PHP Help PHP Coding
  • [RESOLVED] I need help to do with variables on the url and function not working.

Hey all i need some assistance. I am trying to progam a web app that doesn't change page it justs populates the main content area with extenal pages.

The way it works is it takes the content files and show them after the url is

index.php?p=<mod name>&s=<the page the module is using>

the only problem is the get content feature is spitting out
Fatal error: Call to undefined function getContent() in /home/andreffx/public_html/dev/index.php on line 136

the code on that line is

<?php getContent(); ?>

the index.php includes the the file inc/functions.php which contains the following:

<?php
include ('inc/config.php');

function getContent() {

global $p;
global $s;
global $c_path;
global $c_error;

$p_page = $c_path.$p.'.php';
$s_page = $c_path.$p.'/'.$s.'.php';

if (is_file($s_page)) {
	$inc_page = $s_page;
} else {
	if (is_file($p_page)) {
		$inc_page = $p_page;
	} else {
		echo $c_error;
	}
}

if (isset($inc_page)) {
	include($inc_page);
}

}
?>

this file includes config.php wich is as follows.

<?php
if (isset($_GET['p']) && $_GET['p'] != '') {
	$p = $_GET['p'];
} else {
	$p = 'home';
}
if (isset($_GET['s']) && $_GET['s'] != '') {
	$s = $_GET['s'];
}

$c_path = 'mods/';

$c_error = '<li class="red"><span class="ico"></span><strong class="An error has occured, Please notify your I.T Manager</strong></li>;
?>

I really need this to work so i can start my dev again.

Please Help.

    you're missing the closing single quote on the last line of your include file config.php

    
    <?php 
    if (isset($_GET['p']) && $_GET['p'] != '') { 
        $p = $_GET['p']; 
    } else { 
        $p = 'home'; 
    } 
    if (isset($_GET['s']) && $_GET['s'] != '') { 
        $s = $_GET['s']; 
    } 
    
    $c_path = 'mods/'; 
    
    $c_error = '<li class="red"><span class="ico"></span><strong class="An error has occured, Please notify your I.T Manager</strong></li>'; //<-- MISSING SINGLE QUOTE 
    ?>
    
    

      Maybe try changing the include() to a require() (or require_once()) where you include the file that defines the missing function, and see if you get a fatal error (indicating a problem trying to include that file).

      PS: Or what jeepin81 pointed out, above. 🙂

        nogdog your method still displays the same error and jeepin81 im a bit of a noob could you possibly fill in the error you noticed and post it for me to try please.

          i tried all the above methods i can't beleive i was confused when i was told to but in the single quote lol. its still showing the same error up any other ideas?

            can you post more of what is on your index.php page?

              other then that its just html code no other php script there as of yet if you want i can give you access to the source code via pastebin

                aerecords;10993405 wrote:

                other then that its just html code no other php script there as of yet if you want i can give you access to the source code via pastebin

                I suspect that may be necessary, as I think something is there (or not there) that we're not seeing here, or something in the way the pieces are integrated together.

                  4 days later

                  Could you post the index.php file content here?

                    4 days later

                    figured it in the functions.php file when i moved a file dreamweaver must have tried updating links because where it says on line 2 of functions.php its looking for (webroot)/inc/inc/config.php instead of (webroot)/inc/config.php so i had to omit the /inc/.
                    Its days like these that i feel like a right fool lol thanks all for your help anyways.

                      Write a Reply...