我試圖教自己PHP & MySQL。請注意我對此很新。以下是我收到的錯誤消息和所有代碼。致命錯誤:調用未定義的函數get_all_subjects()
我希望這是有道理的!
致命錯誤:調用未定義的函數get_all_subjects()在/Users/darren/Sites/widget_corp/content.php第9行
content.php代碼
<?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(); **// this is the 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"); ?>
這是我的功能代碼它位於名爲「includes」的文件夾中
</php
// This is where we store all the basic functions
function confirm_query($result_set) {
if (!$result_set) {
die("Database selection failed: " . mysql_error());
}
}
function get_all_subjects() {
global $connection;
$query = "SELECT *
FROM subjects
ORDER BY 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 *
FROM pages
WHERE subject_id = {$subject_id"}
ORDER BY position ASC";
$page_set = mysql_query($query, $connection);
confirm_query($page_set);
return $page_set;
}
?>
那是真正的 php嗎? –