1

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.

Thanks!

5
  • How does your query look like and how do you access the data you retrieved?
    – kzidane
    Commented Sep 6, 2014 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. Commented Sep 9, 2014 at 2:27
  • I mean what's the exact statement(s) that you're executing for that purpose?
    – kzidane
    Commented Sep 9, 2014 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? Commented Sep 9, 2014 at 3:10
  • Maybe you should answer your own question and accept the answer!
    – kzidane
    Commented Sep 9, 2014 at 3:45

1 Answer 1

0

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

You must log in to answer this question.

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