I want to take out a user's points from the points field in userpoints table,because i will use it to judge
a inputted number whether is bigger than this user's points,if bigger,drupal will tell you error.but the number taken out from the DB is always incorrect .the following code is my validate function:
function answers_validate(&$node)
{
global $user;
$points_user=$node->favorite_points;
$auid=$user->uid;
if($auid)
{
$totalPoints=(int)db_query('SELECT points FROM {userpoints} WHERE uid=%d',$auid);
if(is_numeric($points_user))
{
if($points_user>0)
{
if($points_user>$totalPoints)
{
form_set_error('favorite_points',t('sorry your inputed points is bigger than your total points,please input a number lessed your total points'));
}
}else
{
form_set_error('favorite_points',t('sorry your inputed points must be bigger than 0'));
}
}else
{
form_set_error('favorite_points', t('Please input a number consisted between 0 and 9'));
}
}
}
$totalPoints=(int)db_query('SELECT points FROM {userpoints} WHERE uid=%d',$auid);
is this sql incorrect?please help me.