Cyb3r
Well-known member
Hi, can anyone please tell me if this queries is correct:
	
	
	
		
For some reason it's not working, however I don't get any error's but still not inserting anything in the field.
Any help will be much appreciated.
				
			
		PHP:
	
	// Check if the field is not set
$value = $db->query("
    SELECT `field_value`
    FROM `xf_user_field_value`
    WHERE `field_id` = 'MyField'
    AND `user_id` = '$userId'
");
// If the field is empty
if(!$value)
{
    // Insert the MyValue into the field
    $db->query("
        UPDATE `xf_user_field_value`
        SET `field_value` = 'MyValue'
        WHERE `field_id` = 'MyField'
        AND `user_id` = '$userId'
    ");
}
	For some reason it's not working, however I don't get any error's but still not inserting anything in the field.
Any help will be much appreciated.
			
				Last edited: