iStriide Posted August 25, 2011 Share Posted August 25, 2011 I am getting this error: Fatal error: Unsupported operand types. <?php $new_player_credits = $player_credits + $game_credits; $new_player_exp = $player_exp + $game_exp; ?> I have absolutely no clue why I'm getting the error. Both of my variables are integers. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 25, 2011 Share Posted August 25, 2011 Use var_dump() on the variables being added and post what the results are for each one. Quote Link to comment Share on other sites More sharing options...
xyph Posted August 25, 2011 Share Posted August 25, 2011 The only time I get this error is when I try to add an array to something. Even an object should return something like Notice: Object of class classname could not be converted to int in file on line x Even using a resource type leads to an error-less adding attempt. Quote Link to comment Share on other sites More sharing options...
iStriide Posted August 25, 2011 Author Share Posted August 25, 2011 I'm using an array and adding it to a number. How can I make it add? Quote Link to comment Share on other sites More sharing options...
xyph Posted August 25, 2011 Share Posted August 25, 2011 You're trying to add an array to a number and wondering why it won't work? You gotta think things through before you start to code Explain to me why you'd want to add an array to an integer. What are the contents of this array? Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 25, 2011 Share Posted August 25, 2011 I'm using an array and adding it to a number. How can I make it add? What? You stated "Both of my variables are integers.". But, now you say you are trying to add an array to a number. I don't even know what that means. You might as well state you are trying to add the color 'blue' to a school of fish. It is illogical. You can add a "value", or "values", in the array to a number. You'd better show what the contents of the array are and what your expectations when "adding" the array to the number are. Quote Link to comment Share on other sites More sharing options...
iStriide Posted August 25, 2011 Author Share Posted August 25, 2011 Don't worry I fixed the problem. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 25, 2011 Share Posted August 25, 2011 Don't worry I fixed the problem. Whew! That's a relief. I don't think I could go on living if you weren't able to add arrays to integers. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.