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. Link to comment https://forums.phpfreaks.com/topic/245713-unsupported-operand-types-error-help/ 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. Link to comment https://forums.phpfreaks.com/topic/245713-unsupported-operand-types-error-help/#findComment-1262044 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. Link to comment https://forums.phpfreaks.com/topic/245713-unsupported-operand-types-error-help/#findComment-1262046 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? Link to comment https://forums.phpfreaks.com/topic/245713-unsupported-operand-types-error-help/#findComment-1262048 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? Link to comment https://forums.phpfreaks.com/topic/245713-unsupported-operand-types-error-help/#findComment-1262049 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. Link to comment https://forums.phpfreaks.com/topic/245713-unsupported-operand-types-error-help/#findComment-1262050 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. Link to comment https://forums.phpfreaks.com/topic/245713-unsupported-operand-types-error-help/#findComment-1262051 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. Link to comment https://forums.phpfreaks.com/topic/245713-unsupported-operand-types-error-help/#findComment-1262053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.