【问题标题】:PHP Simple XML Parser, blank responsePHP Simple XML Parser,空白响应
【发布时间】:2015-02-18 21:46:33
【问题描述】:

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选择码: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>"
  ?>

【问题讨论】:

    标签: php xml parsing curl


    【解决方案1】:

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

    试试:

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

    【讨论】:

      猜你喜欢
      • 2016-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-07
      • 2011-09-04
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      相关资源
      最近更新 更多