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

PHP Simple XML Parser, blank response

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

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

这也是一个项目,所以在有人问之前,为什么你没有任何 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);
  ?>

服务器端PHPselect代码:hinbuy.php

<?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>"
  ?>

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

尝试:

$hin = $_GET["hin"];
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, "http://192.168.0.12/hinbuy.php?hin=" . $hin);