我有一个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) 我想将图像中的白色(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) 我在使用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)