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