简体   繁体   English

无法使用php在远程服务器上创建xml文件

[英]Not able to create xml file on remote server using php

I am developing a php app where I need to fetch some data from MySQL database and create an xml file. 我正在开发一个PHP应用程序,需要从MySQL数据库中获取一些数据并创建一个xml文件。 I have succeeded in doing that in my local server(XAMPP on Windows) but, when I tried to load it from remote server(Linux) I am not getting any output. 我已经在本地服务器(Windows上的XAMPP)上成功完成了此操作,但是,当我尝试从远程服务器(Linux)上加载它时,我没有得到任何输出。

PHP Code: PHP代码:

<?php
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node); 
$connection=mysql_connect ($host, $username, $password);
if (!$connection) {  die('Not connected : ' . mysql_error());} 
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mysql_error());
} 
$query = "SELECT * FROM tracker WHERE 1 LIMIT 1";
$result = mysql_query($query);
if (!$result) {  
  die('Invalid query: ' . mysql_error());
} 

header("Content-type: text/xml"); 
while ($row = @mysql_fetch_assoc($result)){  
  $node = $dom->createElement("marker");  
  $newnode = $parnode->appendChild($node);   
  $newnode->setAttribute("lat", $row['lat']);  
  $newnode->setAttribute("lng", $row['lng']);  
} 
echo $dom->saveXML();
?>

Output I got on local machine: ` 我在本地计算机上得到的输出:

<markers>
<marker lat="17" lng="77"/>
</markers>

On remote server I am getting a 500 Internal Server Error. 在远程服务器上,我收到500内部服务器错误。

The cause can be many-fold - access rights, xml libraries you are missing, php version... 原因可能是多方面的-访问权限,您缺少的xml库,php版本...

can you check the error_log file 你可以检查error_log文件吗

/var/log/httpd/error_log on RHEL RHEL上的/ var / log / httpd / error_log

or 要么

/var/log/apache2/error_log on DEB DEB上的/ var / log / apache2 / error_log

and paste the output from the error? 并粘贴错误的输出?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM