When I query my Database for the number of shares of some user, I get a strange value when converting this value to an int or a float. For instance, my query should return the value of "100" shares but when I cast this value I get "1.00". I think it has something to do with the number_format function. I could multiply by 100 but I just wanted to ask if someone else has the same problem and if it is because the number_format.


  • How does your query look like and how do you access the data you retrieved? – Kareem Sep 6 '14 at 8:47
  • @Kareem I have a sell-form where the user enters the stocks he/she wants to sell. I save this information in a variable ($stocksToSell) and then I pass it to index.php. In index.php I used "query" to retrieve the number of shares the user has for each stock and "lockup" to get the prices. I multiply price times shares and use this information to UPDATE user's cash. – Juan Carlos Piñeros Sep 9 '14 at 2:27
  • I mean what's the exact statement(s) that you're executing for that purpose? – Kareem Sep 9 '14 at 2:55
  • Maybe it would be against the rules to post code. But thank you, I just found the problem... I was using an array so I had to call the function "implode" and now it's working. Should I close the question? Post my own answer? – Juan Carlos Piñeros Sep 9 '14 at 3:10
  • Maybe you should answer your own question and accept the answer! – Kareem Sep 9 '14 at 3:45

My problem was that I was getting an array after querying the Database. I've solved it by using "implode"

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .