PHP简单XML解析器,空白响应

PHP简单XML解析器,空白响应,php,xml,parsing,curl,Php,Xml,Parsing,Curl,PHP简单XML解析器,空白响应。 下面代码的主要问题是,如果没有解析器,它可以正常工作,但是一旦添加了XML解析器,它就可以从客户端连接到其他服务器,它不会返回结果,只是一个空白页 这也是一个项目,所以在有人问之前,为什么没有任何SQLi保护。到目前为止,我还没有实施它 代码如下: 客户端XML解析器代码:hinphp.php <?php $hin = $_GET["hin"]; $connection = curl_init(); curl_setopt($connecti

PHP简单XML解析器,空白响应。

下面代码的主要问题是,如果没有解析器,它可以正常工作,但是一旦添加了XML解析器,它就可以从客户端连接到其他服务器,它不会返回结果,只是一个空白页

这也是一个项目,所以在有人问之前,为什么没有任何SQLi保护。到目前为止,我还没有实施它

代码如下:

客户端XML解析器代码:hinphp.php

<?php
  $hin = $_GET["hin"];
  $connection = curl_init();
  curl_setopt($connection, CURLOPT_URL, "http://192.168.0.12/hinbuy.php?hin="); 
  curl_setopt($connection,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($connection,CURLOPT_HEADER, 0);
  $response = curl_exec($connection);
  $xml = simplexml_load_string($response);
  for($index=0; $index < count($xml->songs); $index++)
  {
        echo $xml->songs[$index]->ID . "<br />";
        echo $xml->songs[$index]->song . "<br />";
        echo $xml->songs[$index]->artist . "<br />";
        echo $xml->songs[$index]->year . "<br />";
        echo $xml->songs[$index]->genre . "<br />";
        echo $xml->songs[$index]->quantity . "<br />";

        $ID = $xml->songs[$index]->ID;
        echo "<a href='http://192.168.0.12/buyclihin.php?ID=$ID'>buy</a>";
  }

  curl_close($connection);
  ?>
<?php
  header("Content-type: text/xml");
  echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
  echo "<hit>";
  $hin = $_GET["hin"];
  $conn = new PDO("mysql:host=localhost;dbname=xxxxx;","xxxxx","xxxxx");
  $results = $conn->query("SELECT * FROM `ghit` WHERE `artist`='$hin'");
  while($row=$results->fetch())
  {
  echo "<songs>";
  echo "<id>$row[ID]</id>";
  echo "<song>$row[song]</song>";
  echo "<artist>$row[artist]</artist>";
  echo "<year>$row[year]</year>";
  echo "<genre>$row[genre]</genre>";
  echo "<quantity>$row[quantity]</quantity>";
  echo "</songs>";
  }
  echo "</hit>"
  ?>
歌曲)$索引++)
{
echo$xml->songs[$index]->ID.“
”; echo$xml->歌曲[$index]->歌曲。“
”; echo$xml->songs[$index]->artist.“
”; echo$xml->songs[$index]->year.“
”; echo$xml->歌曲[$index]->流派。“
”; echo$xml->歌曲[$index]->数量。“
”; $ID=$xml->songs[$index]->ID; 回声“; } 旋涡关闭($连接); ?>
服务器端PHP选择代码:hinbuy.PHP

<?php
  $hin = $_GET["hin"];
  $connection = curl_init();
  curl_setopt($connection, CURLOPT_URL, "http://192.168.0.12/hinbuy.php?hin="); 
  curl_setopt($connection,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($connection,CURLOPT_HEADER, 0);
  $response = curl_exec($connection);
  $xml = simplexml_load_string($response);
  for($index=0; $index < count($xml->songs); $index++)
  {
        echo $xml->songs[$index]->ID . "<br />";
        echo $xml->songs[$index]->song . "<br />";
        echo $xml->songs[$index]->artist . "<br />";
        echo $xml->songs[$index]->year . "<br />";
        echo $xml->songs[$index]->genre . "<br />";
        echo $xml->songs[$index]->quantity . "<br />";

        $ID = $xml->songs[$index]->ID;
        echo "<a href='http://192.168.0.12/buyclihin.php?ID=$ID'>buy</a>";
  }

  curl_close($connection);
  ?>
<?php
  header("Content-type: text/xml");
  echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
  echo "<hit>";
  $hin = $_GET["hin"];
  $conn = new PDO("mysql:host=localhost;dbname=xxxxx;","xxxxx","xxxxx");
  $results = $conn->query("SELECT * FROM `ghit` WHERE `artist`='$hin'");
  while($row=$results->fetch())
  {
  echo "<songs>";
  echo "<id>$row[ID]</id>";
  echo "<song>$row[song]</song>";
  echo "<artist>$row[artist]</artist>";
  echo "<year>$row[year]</year>";
  echo "<genre>$row[genre]</genre>";
  echo "<quantity>$row[quantity]</quantity>";
  echo "</songs>";
  }
  echo "</hit>"
  ?>
query(“从`ghit`中选择*,其中`artist`='$hin'”);
而($row=$results->fetch())
{
回声“;
回显“$row[ID]”;
回声“$行[歌曲]”;
回声“$行[艺术家]”;
回显“$行[年]”;
回声“$行[流派]”;
回显“$行[数量]”;
回声“;
}
回声“”
?>

这可能是因为您没有将
$hin
传递给
hibbuy.php

尝试: