php - Fatal error: Call to undefined function get_all_subjects() in -
i trying teach myself php & mysql. please note new this. below error message getting , code.
i hope makes sense!!!
fatal error: call undefined function get_all_subjects() in /users/darren/sites/widget_corp/content.php on line 9
content.php code
<?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?> <?php include("includes/header.php"); ?> <table id="structure"> <tr> <td id="navigation"> <ul class="subjects"> <?php $subject_set = get_all_subjects(); **// problem line** while ($subject = mysql_fetch_array($subject_set)) { echo "<li><a href=\"content.php?subj=" . urlencode($subject["id"]) . "\">{$subject["menu_name"]}</a></li>"; $page_set = get_pages_for_subject($subject["id"]); echo "<ul class=\"pages\">"; while ($page = mysql_fetch_array($page_set)) { echo "<li><a href=\"content.php?page=" . urlencode($page["id"]) . "\">{$page["menu_name"]}</a></li>"; } echo "</ul>"; } ?> </ul> </td> <td id="page"> <h2>content area</h2> </td> </tr> </table> <?php require("includes/footer.php"); ?>
this functions code resides in folder called "includes"
</php // store basic functions function confirm_query($result_set) { if (!$result_set) { die("database selection failed: " . mysql_error()); } } function get_all_subjects() { global $connection; $query = "select * subjects order position asc"; $subject_set = mysql_query($query, $connection); confirm_query($subject_set); return $subject_set; } function get_pages_for_subject($subject_id) { global $connection; $query = "select * pages subject_id = {$subject_id"} order position asc"; $page_set = mysql_query($query, $connection); confirm_query($page_set); return $page_set; } ?>
your functions code has mal-formed opening <?php
tag - you've got </php
. without opening tag, php process file plaintext , never treat php code. means function never got defined.
remember there not such things "php script". there text files happen contain php code blocks. opening <?php
tag required @ point in file, otherwise 'code' text.
Comments
Post a Comment