我最近將我的網站移動到新的服務器。網站被移動後,PHP分頁停止工作。沒有任何代碼已經改變。是否需要進行任何配置更改?移動到新服務器後的分頁問題
下面是代碼:
mysql_connect("host", "username", "password") or die(mysql_error());
mysql_select_db("playstat_page") or die(mysql_error());
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
//count the number of results
$data = mysql_query("SELECT * FROM test") or die(mysql_error());
$rows = mysql_num_rows($data);
//number of results displayed per page
$page_rows = 20;
//page number of our last page
$last = ceil($rows/$page_rows);
//makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
//sets the range to display in our query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
$data_p = mysql_query("SELECT * FROM test ORDER BY ID DESC $max") or die(mysql_error());
while($info = mysql_fetch_array($data_p))
{
$posted = date('F j, Y g:i a', strtotime($info["Posted"]));
Print "<p>{$info["Head"]}</p><br></br>";
}
if ($pagenum == 1)
{
}
else
{
$previous = $pagenum-1;
Print "<div id='pagenav'>
<ul style='float: left; margin-left: -25px;'>
<li><a href='{$_SERVER['PHP_SELF']}?pagenum=1'>First</a></li>
<li><a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'>Previous</a></li>
</ul>
</div>";
}
if ($pagenum == $last)
{
}
else
{
$next = $pagenum+1;
Print "<div id='pagenav'>
<ul style='float:right'>
<li><a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next</a></li>
<li><a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last</a></li>
</ul>
</div>";
}
如果分頁位於您的代碼中,我們將無法告訴您任何內容,因爲當您從一個php版本更改爲另一個php版本時,可能會有一打可能干擾腳本任何部分的更改 – ITroubs
添加代碼,你有什麼警告? – cmorrissey
你使用PHP來做你的分頁,你是否依賴htaccess?需要更多信息。此刻,你告訴我們這輛車壞了,但不要告訴我們什麼壞事。 – MueR