Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For sake of completeness (as I can't add comments yet), let me also add this detail as another answer:</p> <p>(Edit: To be read after realizing that the source data (i.e. in the OP's case, database result set) could be the problem (by returning numeric columns as strings), and json_encode() in fact was not the source of the problem)</p> <p>Manual pages of both "<a href="http://us.php.net/manual/en/function.mysql-fetch-array.php" rel="nofollow">mysql_fetch_array</a>":</p> <blockquote> <p>Returns an <strong>array of strings</strong> that corresponds to the fetched row,</p> </blockquote> <p>... and "<a href="http://us.php.net/manual/en/function.mysql-fetch-row.php" rel="nofollow">mysql_ fetch_ row</a>":</p> <blockquote> <p>Returns an numerical <strong>array of strings</strong> that corresponds to the fetched row</p> </blockquote> <p>clearly states that; the entries in the returned array will be strings.</p> <p>(I was using the DB class in phpBB2 (yes I know, it's obsolete!), and "sql_fetchrow()" method of that class uses "mysql_fetch_array()")</p> <p>Not realizing that, I also ended up finding this question, and understanding the problem! :)</p> <p>As Pascal Martin stated above in his follow-up comments, I believe a solution that takes care of the "incorrect type" problem at the source (i.e. by using the "<a href="http://us.php.net/manual/en/function.mysql-field-type.php" rel="nofollow">mysql_field_type()</a>" function and doing the casting right after fetch, (or other fetch methods like "object"?)) would be the better in general.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload