2
我在寫一個查詢時遇到了一些問題(請參閱下文)。堆棧空間不足錯誤
<?php
require("phpfile.php");
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Opens a connection to a MySQL server
$connection=mysql_connect ("hostname", $username, $password);
if (!$connection) { die('Not connected : ' . mysql_error());}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
$query = "SELECT userdetails.userid
, detectinglocations.locationid
, detectinglocations.locationname
, finds.findid
, finds.locationid
, finds.findosgb36lat
, finds.findosgb36lon
, finds.dateoftrip
, finds.findcategory
, finds.findname
,finds.finddescription
, finds.detectorsettings
, finds.pasref
, finds.additionalcomments
, detectors.detectorname
, searchheads.searchheadname
FROM userdetails, detectinglocations, finds, detectors, searchheads
WHERE finds.userid=userdetails.userid
AND finds.locationid=detectinglocations.locationid
AND finds.detectorid=detectors.detectorid
AND searchheads.detectorid=detectors.detectorid";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("findid",$row['findid']);
$newnode->setAttribute("locationid",$row['locationid']);
$newnode->setAttribute("locationname",$row['locationname']);
$newnode->setAttribute("dateoftrip",$row['dateoftrip']);
$newnode->setAttribute("findcategory",$row['findcategory']);
$newnode->setAttribute("findname",$row['findname']);
$newnode->setAttribute("finddescription",$row['finddescription']);
$newnode->setAttribute("detectorname",$row['detectorname']);
$newnode->setAttribute("searchheadname",$row['searchheadname']);
$newnode->setAttribute("detectorsettings",$row['detectorsettings']);
$newnode->setAttribute("pasref",$row['pasref']);
$newnode->setAttribute("additionalcomments",$row['additionalcomments']);
}
echo $dom->saveXML();
?>
當我通過我的網頁瀏覽器上運行PHP腳本它檢索正確的數據,但是當我通過HTML頁面運行此我得到一個「的堆棧」的錯誤。從我在網上閱讀的內容來看,我認爲這可能是因爲SQL查詢太複雜了。
你能告訴我一個過於複雜的SQL查詢會導致這種類型的錯誤嗎?
PHP是一個服務器端語言,所以我想不通「通過Web瀏覽器」,什麼「雖然HTML頁面「是指在這種情況下,它們有何不同。 –
查詢絕對不是太複雜。你的代碼一次只處理一行,你每次獲取的數據量是有限的。 – Johan
嗨,非常感謝回覆我的帖子。我明白,PHP是基於服務器的,但通過使用php文件名並將其輸入到Web瀏覽器的地址框中,您可以看到從「後端」拉取的數據。這與使用html表單作爲Web地址明顯不同。我希望這是有道理的?親切的問候Chris – IRHM