Although @Explosion Pills works in this case for @user1032531's needs, it's not addressing the 1st source of the problem.
As you can see in the original question, on the PHP side the value from sell_price
is already a string
, although, as the user said, in the database it's stored as a "number" (we don't know if it's a DECIMAL
or a FLOAT
).
Well, when using PDO with MySQL a proper config may be required in order to get "numbers" as "numbers", as user @jameshfisher pointed out in his comment. You can follow his link in order to get almost everything you need to get it working.
Appart from that, the accepted answer is working because without the use of the JSON_NUMERIC_CHECK
json_encode
will send everything as text no matter the type of the variable, and when using it it will convert the value to a type based on guesses rather than the type of the original var.