appendChild($node); // Opens a con-6ren">
gpt4 book ai didi

php - 堆栈空间不足错误

转载 作者:行者123 更新时间:2023-11-29 03:11:38 25 4
gpt4 key购买 nike

我在编写查询时遇到了一些问题(请参阅下文)。

<?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 页面运行它时,我得到一个“Out of Stack”错误。从网上看的,我觉得可能是SQL查询太复杂了。

你能告诉我过于复杂的 SQL 查询会导致这种类型的错误吗?

最佳答案

您的数据有问题/意外。

1) 在每个循环的顶部执行 file_put_contents("somedumpfile", var_export($row, true)) ,并查看进程终止后文件中的内容。2) 如果这没有帮助,则系统地一次从上到下删除一个字段,使其不被添加为节点。当您不再收到错误时,您就找到了罪魁祸首。3) 如果仍然没有帮助,开始重新添加字段作为节点,从上到下。

确保 PHP 错误日志已完全启用,并查看 PHP 是否提示其他问题。还要考虑将行索引和 PHP 的当前内存消耗 (memory_get_usage) 转储到同一个文件中。

祝你好运。分享您的结果。

(如果你喜欢/接受这个答案,请给我投票。)

达斯汀

关于php - 堆栈空间不足错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7311582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com