2 Replies - 629 Views - Last Post: 30 April 2009 - 05:36 PM Rate Topic: -----

#1 LemonMan  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 170
  • Joined: 22-August 05

Can someone help me this error? It's probably a simple fix.

Post icon  Posted 30 April 2009 - 03:49 PM

Hi I'm a PHP noob but an old-time programmer in other languages. When I try to execute this line:

$lower = floor($items / 2);



I get the "Fatal error: Unsupported operand types in /home/www/[mysite]/[myfile] on line 20" error. Can anyone see what I'm doing wrong?

$lower does not occur anywhere else, and $items contains the # of items in an array, as returned by array_count_values. Thanks for your help!

Is This A Good Question/Topic? 0
  • +

Replies To: Can someone help me this error? It's probably a simple fix.

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: Can someone help me this error? It's probably a simple fix.

Posted 30 April 2009 - 04:32 PM

This works for me:
<?php
$items = 3;
$lower = floor($items / 2);
echo $lower;
?>

so I think there must be more going on than you're showing us.
Was This Post Helpful? 0
  • +
  • -

#3 LemonMan  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 170
  • Joined: 22-August 05

Re: Can someone help me this error? It's probably a simple fix.

Posted 30 April 2009 - 05:36 PM

View PostCTphpnwb, on 30 Apr, 2009 - 04:32 PM, said:

so I think there must be more going on than you're showing us.


You are right. There was nothing wrong with that line; I just found the problem. I was calling array_count_items or something like that instead of just "count".
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1