【问题标题】:Parse error: syntax error, unexpected end of file in [duplicate]解析错误:语法错误,[重复]中的文件意外结束
【发布时间】:2015-04-26 10:16:00
【问题描述】:

我有用于导出到 XML 的代码 id PHP,但我不知道问题出在哪里?

<?php  

$data=mysql_query("SELECT * FROM ``");

while($zaznam=mysql_fetch_array($data)){

$select = "select * from `` WHERE ID=".$zaznam['ID']."";
$proved =  mysql_query($select) or die ( mysql_error() );

$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<Kurzy>\n";

for($x = 0 ; $x < mysql_num_rows($proved) ; $x++){
$row = mysql_fetch_assoc($proved);

$xml_output .= "\t<Kurz>\n";

$xml_output .= "\t</Kurz>\n";   
}

$xml_output .= "</Kurzy>";  
echo $xml_output;      
?>

我的代码有时会写错误,有时不会。问题出在哪里?

【问题讨论】:

  • 两个开头{,一个结尾}....这是不匹配
  • 试试缩进你该死的代码。

标签: php html mysql xml


【解决方案1】:

缺少最接近的while循环}最后一行

$data=mysql_query("SELECT * FROM ``");

while($zaznam=mysql_fetch_array($data)){

$select = "select * from `` WHERE ID=".$zaznam['ID']."";
$proved =  mysql_query($select) or die ( mysql_error() );

$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<Kurzy>\n";

for($x = 0 ; $x < mysql_num_rows($proved) ; $x++){
$row = mysql_fetch_assoc($proved);

$xml_output .= "\t<Kurz>\n";

$xml_output .= "\t\n";
}

$xml_output .= "</Kurzy>";  
echo $xml_output;   
}
?>

【讨论】:

  • 不客气,如果这解决了您的问题,请接受答案
猜你喜欢
  • 2017-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-12
  • 1970-01-01
相关资源
最近更新 更多