English 中文(简体)
计数1
原标题:array_sum() expects parameter 1 to be array
  • 时间:2012-01-14 13:12:25
  •  标签:
  • php
  • arrays

需要有人帮助我打下以下几句。

在我的当地机器上,我马上有一米运行MAMP。 我有以下法典:

   $x=0;
   for ($i=0; $i<=30; $i++) {
       $VoteValue[$x] = $i;
       $x++;
   }

   $Total = array_sum($VoteValue);
   echo "<br /><br />Total Vote = $Total <br />";

上述法典在我的当地机器上运作并课以罚款。 但是,当我将其上载到我的生产服务器时,我收到以下警告:

Warning: array_sum() expects parameter 1 to be array, null given in /home/RIP/public_html/RIPVote.php on line 7

由于警告错误,它没有回报,并显示产出价值。 如何消除这种情况?

请尽快听取你的意见。 赞赏和感谢。

最佳回答

Hmm, weird, i dont knowledge what the mis is in their Code, buttries this out:

$VoteValue = array();
for ($i=0; $i<=30; $i++) {
           $VoteValue[] = $i;
       }

       $Total = array_sum($VoteValue);
       echo "<br /><br />Total Vote = $Total <br />";
问题回答

您是否尝试过Voteue,

$VoteValue = array();

?

总计0至n = (无*(n+1)) 页: 1

这样做。 我希望这有助益。

$VoteValue = [];

for ($i=0; $i<=30; $i++) {
     array_push($VoteValue, $i);
}

$Total = array_sum($VoteValue);

echo "<br /><br />Total Vote = $Total <br />";

i v tried,on the ubuntu11.04 with lampp. no errors.

总票数: 465

也许可能的话,问题就在于:

<?php
       $VoteValue = range(0, 30);
       $Total = array_sum($VoteValue);
       echo "<br /><br />Total Vote = $Total <br />";
?>

您可使用<条码>。

契约法典:

<?php echo  <br /><br />Total Vote =  .array_sum(range(0, 30)).  <br /> ; ?>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签