First off, you shouldn't have quotes around the $v because that implies it's a string and I'm pretty sure it's a number?
Is the result going to be just one threadid? If so use query_read_first (I think that's it - doing it from memory) and then leave out the whole next four line (the if with the parenthesis) and just say
HTML Code:
$ytvideoid = $ytvideo[threadid];
(No need for the whole fetch_array thing when using query_first)