这是错误:
致命错误:在第 13 行的 file.php 中调用未定义函数 get_page_by_id()
下面是调用该函数的代码:
<?php
require_once("includes/connect.php");
include("includes/functions.php");
?>
<?php
if (isset($_GET['info'])){
$sel_table1 = get_info_by_id($_GET['info']);
$sel_t2 = 0;
$table2 = NULL;
} elseif (isset($_GET['page'])){
$table1 = 0;
$sel_table1 = NULL;
$table2 = get_page_by_id($_GET['page']);
} else {
$table1 = 0;
$sel_table1 = NULL;
$table2 = 0;
}
?>
这是我的functions.php这个函数的代码:
function get_page_by_id($page_id){
$query = "SELECT *";
$query .= " FROM pages ";
$query .= " WHERE id=" . $page_id;
$query .= " LIMIT 1";
$result_set = mysql_query($query);
confirm_query($result_set);
if ($page = mysql_fetch_array($result_set)){
return $page;
} else {
return NULL;
}
}
我不知道该怎么想,哈哈。当该函数的函数和变量为真时,就会发生这种情况。
谢谢
更新:这是我的全部functions.php:
<?php
function confirm_query($result_set){
if(!$result_set){
die("Could not connect to database.");
}
}
function get_all_info(){
$result = mysql_query("SELECT * FROM information ORDER BY position ASC");
confirm_query($result);
return $result;
}
function get_pages_for_info($information_id){
$result2 = mysql_query("SELECT * FROM pages WHERE information_id ={$information_id} ORDER BY position ASC");
confirm_query($result2);
return $result2;
}
function get_info_by_id($information_id){
$query = "SELECT * ";
$query .= "FROM information ";
$query .= "WHERE id=" . $information_id;
$query .= " LIMIT 1";
$result_set = mysql_query($query);
confirm_query($result_set);
if ($info = mysql_fetch_array($result_set)){
return $info;
} else {
return NULL;
}
}
function get_page_by_id($page_id){
$query = "SELECT *";
$query .= " FROM pages ";
$query .= " WHERE id=" . $page_id;
$query .= " LIMIT 1";
$result_set = mysql_query($query);
confirm_query($result_set);
if ($page = mysql_fetch_array($result_set)){
return $page;
} else {
return NULL;
}
}
?>