I want to get the value from a column in a mysql table. The value from the mysql row is a simple number of 2 figures. (40) I tried:
$healthh = intval(mysql_query("SELECT health FROM users
WHERE username = ".quote_smart($username).""));
and in print_r($healthh);
I get 33 instead of 40.
tried also
$healthh = mysql_query("SELECT health FROM users
WHERE username = ".quote_smart($username)."");
OUTPUT IS in this case Resource id #33
if i try like this:
$healthh = mysql_fetch_object(mysql_query("SELECT health FROM users
WHERE username = ".quote_smart($username).""));
I get the right value but not as an integer (a simple 2 figure number) OUTPUT: stdClass Object ( [health] => 40 )
Any ideas?
Use mysql_fetch_asoc()
$result = mysql_query("SELECT health FROM users
WHERE username = ".quote_smart($username)."");
$row = mysql_fetch_assoc($result);
$healthh = $row['health'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.