小编Sor*_*yyx的帖子

cURL和PHP显示"1"

我有一个PHP脚本,我想从数据库读取服务器并使用cURL连接到它们.服务器响应sql查询的结果.问题是每个服务器响应后的脚本显示数字1.输出如下所示:

服务器1:一些结果

1Server 2:一些结果

1Server 3:一些结果

1

以下是从数据库读取服务器并连接到它们的代码:

<?php

$mysql_id = mysql_connect('localhost', 'ms', 'pass');
mysql_select_db('servers', $mysql_id);
mysql_query("SET NAMES utf8");

$query = "SELECT * FROM svr";
$result = mysql_query($query);
$num = mysql_num_rows($result);
while ($data = mysql_fetch_assoc($result))
{
    $server[] = $data;
}

mysql_close($mysql_id);

$i = 0;
while($i < $num) {
    $dealer = $server[$i]['dealer'];

    echo $dealer . "<br />";

    $data = "val=a"; //just for testing                                                                    

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);    
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                                                                                                       
        'Content-Type: text/html; charset=utf-8') …
Run Code Online (Sandbox Code Playgroud)

php mysql database curl

23
推荐指数
2
解决办法
2万
查看次数

工具栏中抽屉切换的徽章通知 - Android

我想在应用程序中通知用户有关新的未读消息,可以通过导航抽屉访问.我正在考虑类似Apple的通知徽章,但工具栏中的抽屉切换.

这就是我现在拥有的: 这就是我现在拥有的

这就是我要的: 这就是我要的

我怎样才能做到这一点?

android android-layout navigation-drawer android-toolbar

18
推荐指数
3
解决办法
7045
查看次数

PHP中的imagecolortransparent无法正常工作

我想将图像中的白色(http://www.arso.gov.si/vreme/napovedi%20in%20podatki/radar.gif)更改为透明.我认为代码看起来正确,没有错误日志,但图片保持不变.我仔细检查图像中的颜色是否真的是白色而且是.请帮忙.

<?php
    $im = imagecreatefromgif("http://www.arso.gov.si/vreme/napovedi%20in%20podatki/radar.gif");

    imagealphablending($im, false);
    imagesavealpha($im, true);

    $white = imagecolorallocate($im, 255, 255, 255);

    imagecolortransparent($im, $white);

    imagegif($im, './image_radar_tran.gif');
    imagedestroy($im);
?>
<body style="background-color: lightgoldenrodyellow;">
    <img src="./image_radar_tran.gif" />
</body>
Run Code Online (Sandbox Code Playgroud)

php image image-processing

5
推荐指数
1
解决办法
3873
查看次数

使用jQuery/JavaScript从SOAP响应中解析XML

我在使用jQuery解析来自SOAP服务器的响应时遇到问题.我想将XML响应转换为数组,因为有多行数据,如下所示.

这是请求:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetWorkPos xmlns="http://localhost/apps">
      <id>int</id>
    </GetWorkPos>
  </soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

这是回应:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetWorkPosResponse xmlns="http://localhost.com/apps">
      <GetWorkPosResult>
        <GetWorkPos>
          <ProductId>string</ProductId>
          <Product>string</Product>
          <quantity>decimal</quantity>
          <Em>string</Em>
          <type>string</type>
        </GetWorkPos>
        <GetWorkPos>
          <ProductId>string</ProductId>
          <Product>string</Product>
          <Quantity>decimal</Quantity>
          <Em>string</Em>
          <Type>string</Type>
        </GetWorkPos>
      </GetWorkPosResult>
    </GetWorkPosResponse>
  </soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

   $(document).ready(function () {
   $("#send").click(function (event) {
            var wsUrl = "http://localhost/Service.asmx";

            var soapRequest =
            '<?xml version="1.0" encoding="utf-8"?> \
            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
                xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
                xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> \
              <soap:Body> \
                <GetWorkPos xmlns="http://localhost.com/apps"> \
                  <id>' + $("#id").val() + …
Run Code Online (Sandbox Code Playgroud)

javascript jquery parsing soap

4
推荐指数
1
解决办法
3万
查看次数