堆叠空间错误

时间:2011-09-05 18:28:34

标签: php mysql sql

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

<?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 个答案:

答案 0 :(得分:1)

您的数据存在错误/意外。

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

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

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

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

达斯汀

相关问题