這可能是一個register_globals = on問題或url重寫問題。我通過使用基本的PHP鏈接語法消除了URL重寫的可能性。我嘗試了幾個補丁來模擬register_globals,但無濟於事。直到上週php.ini文件更新後,該網站才能正常運行。它是一個使用php 5.4.23的Apache服務器。 基本上我有一個目錄頁面,顯示從mysql數據庫調用的作品列表。當用戶點擊鏈接時,它會將用戶帶到適當的項目頁面。目錄列表正確顯示,但鏈接不再起作用,並且沒有顯示錯誤。它始終鏈接到mysql請求的第一項,而不是所請求的鏈接,即使顯示的URL是正確的。 這裏是連接到數據庫的代碼:鏈接無法運作,因爲PHP 5.4
<?php
$db = mysql_connect("localhost", "user", "pw");
mysql_select_db("database_name",$db);
$sqlNum = 'SELECT * FROM callejas ORDER BY engname ';
$sql = 'SELECT * FROM callejas ORDER BY engname LIMIT '.(($page-1)).",".(1);
$resultNum = mysql_query($sqlNum);
$numRows = mysql_num_rows($resultNum);
$sqlnext = 'SELECT * FROM callejas ORDER BY engname LIMIT ' .(($page)).",".(1);
$sqlpre = 'SELECT * FROM callejas ORDER BY engname LIMIT ' .(($page-2)).",".(1);
//sommaire
$req = 'SELECT * FROM callejas ORDER BY engname ';
$result = mysql_query($req);
$result1 = mysql_num_rows($result);
$milieu = $result1/2;
$mil = (int)$milieu ;
$left = 'SELECT * FROM callejas ORDER BY `engname` ASC LIMIT 0,'.($mil);
$right = 'SELECT * FROM callejas ORDER BY `engname` ASC LIMIT '.($mil).",".($result1);
?>
這裏是catalog.php文件的一部分,其功能除了正確的鏈接
<?
include ("connecttodatabase.php");
$i=1;
$j=0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div align="right" id="left" style="position:absolute; width:200px; height:388px; z-index:42; left: 6px; top: 170px;" class="interline30">
<?
$leftres = mysql_query($left);
function StandardizeString($img)
{
$img = strtr($img,
'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ',
'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
$img = preg_replace('/[\'"]/', '',$img); // Eliminate all quotes
$img = preg_replace('/[^a-zA-Z0-9]+/', '-', $img); // Remove all spaces
$img = trim($img, '_'); // Remove any leading or trailing underscored
// Return the result
return $img;
}
while(($myrow = mysql_fetch_array($leftres)))
{
$img= $myrow['engleg'] ;
$little = "".$myrow['little'];
$tittle = StandardizeString($img);
?>
<div align="center"
<?
echo "id=\"$i\"";
?>
style="position:absolute; width:153px; z-index:49; left: 207px;top:
<?
echo "$j px;"
?>
visibility: hidden;">
<?
echo "<img src= \"{$little}\" title= \"{$img}\" alt= \"{$img}\">";
?>
</div>
<?
echo "<p><a href='works.php?tittle=$tittle&page=$i'
$img</a></p>";
$i++;
$j = $j+30;
}
?>
</div>
</body>
我一直沒能看到什麼錯誤。這段代碼已經運行好幾年了,在閱讀了php 5.3和5.4之間的區別之後,我沒有看到任何已棄用的代碼 ,但我知道register_globals已打開。
您是否曾嘗試在您的網址之前添加'/'? – Peon
剛試過。沒有,這是行不通的。給我一個404錯誤。正如我所說,這已經工作了幾年。 – Rich
您是否檢查過是否啓用了short_open_tag? –