School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
You're Browsing As A Guest! Register Now...
Become an Expert!

Join 357,969 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,567 people online right now.Registration is fast and FREE... Join Now!



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

52 Weeks of Code Challenge: Android

Week #11 of the 52 Weeks of Code Challenge is Android, you should give it a shot. Click Here!

Can someone help me this error? It's probably a simple fix. Fatal error: Unsupported operand types Rate Topic: -----

#1 LemonMan  Icon User is offline

  • D.I.C Head
  • Icon

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


Dream Kudos: 205

Post icon  Posted 30 April 2009 - 02: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!
Was This Post Helpful? 0
  • +
  • -


#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • Icon

Reputation: 210
  • View blog
  • Posts: 2,405
  • Joined: 08-August 08


Dream Kudos: 100

Expert In: PHP

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

Posted 30 April 2009 - 03: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
  • Icon

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


Dream Kudos: 205

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

Posted 30 April 2009 - 04: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
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month