How do I fetch an integer value from the database?
$query = mysql_query('select number from table_name where UNIQUE_ID =SOME_UNIQUE_ID');
I am unable to access the integer value using the query above.
How do I fetch an integer value from the database?
$query = mysql_query('select number from table_name where UNIQUE_ID =SOME_UNIQUE_ID');
I am unable to access the integer value using the query above.
收起
As many have commented, it's unclear what is the problem your are facing.
The $query
variable you are obtaining is NOT the integer you want but a "query object" (or False
if the query failed). You have to extract at least a row using (e.g.) $t=mysql_fetch_array($query)
. The wanted value will be in $t[0]
.
Keep in mind, anyway, that the result of a query is tipically a string, so you have to extract its integer value using intval($t[0])
.
报告相同问题?