doushenyi9104 2011-01-17 22:51
浏览 30
已采纳

需要帮助基本的php和xml

I'm really new to xml, with this being my first dip into it.

I'm trying to add some text to an image using php and xml.

I keep getting the following error: Parse error: syntax error, unexpected '}' in /home/a8744502/public_html/userbar.php on line 18

Below is my code.

<?php
header ("Content-type: image/jpeg");

$doc = new DOMDocument();
$doc->load( "http://phogue.net/feed/". LIBXML_DTDLOAD );

$procon = $doc->getElementsByTagName( "procon" );

$packages = $procon->getElementsByTagName( "package" );
$value = 0;

foreach($packages as $package)
{
  $downloadsA = $package->getElementsByTagName( "downloads" );
  $downloads = $downloadsA->item(0)->nodeValue;

  $value = $downloads + $value
}                                           
$font  = "visitor1.tff";
$font  = 4;
$im = ImageCreateFromjpeg("procon_plugindeveloper.jpg");
$x = 360;
$y = 0;
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 255, 255, 255);
imagestring ($im, $font, $x, $y,  $value, $text_color);
imagejpeg ($im);
?>

The xml file is of the form

<procon>
-<packages>
--<package>
---<downloads>
---</doanloads>
--</package>

--<package>
---<downloads>
---</doanloads>
--</package>

--<package>
---<downloads>
---</doanloads>
--</package>


-</packages>
</procon>

The idea is that it should print out the sum of all the downloads tags that are contained in .

Any help is appreciated :-)

  • 写回答

3条回答 默认 最新

  • douqing5981 2011-01-17 22:54
    关注
      $value = $downloads + $value
    }   
    

    missing a ;

    can't say if that'll make it work though.

    also you probably mean $value .= $downloads + $value; to add on top of the $value variable, else it will just get overwritten each iteration

    edit:

    you can also just do:

    $value += $download; //$value equals $value + $download

    to really confuse you !

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化