Jump to content

Recommended Posts

I'm following a tutorial making a custom CMS.  they were using subjects and pages and I decided just to use subjects as I didn't have seperate pages to the subject.

 

The error message I am getting is,

 

Fatal error: Call to undefined function get_pages_for_subject() in C:\wamp\www\cms\includes\functions.php on line 99

 

This is the code

 

function public_navigation($sel_subject, $sel_page, $public = true) {
	$output = "<ul class=\"subjects\">";
	$subject_set = get_all_subjects($public);
	while ($subject = mysql_fetch_array($subject_set)) {
		$output .= "<li";
		if ($subject["id"] == $sel_subject['id']) { $output .= " class=\"selected\""; }
		$output .= "><a href=\"index.php?subj=" . urlencode($subject["id"]) . 
			"\">{$subject["menu_name"]}</a></li>";
		if ($subject["id"] == $sel_subject['id']) {	
			[b]$page_set = get_pages_for_subject($subject["id"], $public);[/b]
			$output .= "<ul class=\"pages\">";
			while ($page = mysql_fetch_array($page_set)) {
				$output .= "<li";
				if ($page["id"] == $sel_page['id']) { $output .= " class=\"selected\""; }
				$output .= "><a href=\"index.php?page=" . urlencode($page["id"]) .
					"\">{$page["menu_name"]}</a></li>";
			}
			$output .= "</ul>";
		}
	}
	$output .= "</ul>";
	return $output;
}

 

And this is the page it is on

 

<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>

<?php find_selected_page(); ?>
<?php include("includes/header.php"); ?>
<div id="nav">
	<?php echo public_navigation($sel_subject, $sel_page); ?>
	</div>
<div id="banner">
		</div>
		<div id="line">
		</div>
<div id="content"


		<?php if ($sel_subject) { ?>
			<h2><?php echo htmlentities($sel_subject['menu_name']); ?></h2>
			<div class="page-content">
				<?php echo strip_tags(nl2br($sel_subject['content']), "<b><br><p><a>"); ?>
			</div>
		<?php } else { ?>

		<?php } ?>

</div>

<?php include("includes/footer.php"); ?>

 

Thanks Josh

Link to comment
https://forums.phpfreaks.com/topic/201668-undefined-function-problem/
Share on other sites

The error means what it states - you don't have a function named get_pages_for_subject() defined in a place where public_navigation() can 'see' it.  This either means it exists somewhere, and needs to be included, or it doesn't exist, and it's up to you to create it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.