【发布时间】:2014-12-11 08:45:54
【问题描述】:
我在 profile.php 中有这段代码:
$table_to_paginate = 'updates';
$posts_per_page = 5;
require_once ("pagination/start_pagination.php");
$query = "SELECT * FROM updates ";
$query .= " ORDER BY id DESC ";
$query .= " LIMIT {$start}, {$posts_per_page}";
在包含的文件中,即“pagination/start_pagination.php”我有这些代码:
//max displayed per page
$per_page = $posts_per_page;
//get start variable
if(isset($_GET['start'])) {
$start = $_GET['start'];
}
//count records
if(!isset($additional_info)){$additional_info = NULL;}
$counting = "SELECT * FROM {$table_to_paginate}";
$counting .= "{$additional_info}";
$record_count = mysql_num_rows(mysql_query($counting));
//count max pages
$max_pages = $record_count / $per_page; //may come out as decimal
if (!isset($start)) {
if(isset($upsidedown)){
if($record_count - $per_page < 0 ){ $start = 0;} else {$start = $record_count - $per_page;}
} else {
$start = 0;
}
}
问题是,include 可以找到该文件,但它不提供包含文件中的变量,因此我可以在 profile.php 中使用它。有趣的是,它适用于本地主机,但是当我将其上传到服务器时它不起作用。
附加信息:我需要包含文件中的 $start。
【问题讨论】:
-
服务器和localhost相差多少?
-
如果你在包含的文件中加入
echo语句,你看到输出了吗? -
是的。 echo 有效,但即使在 echo 语句中,也无法从包含的文件中找到任何变量。