Your onClick attribute misses the trailing single quote. Here's what I think it should be:
printf("<a href='/r?%s' target=_blank onClick='window.open(location.href=$siteurl/%s-%s.html)'>", $wurl, $myrow["wallpaperid"], $myrow["wallpapername"]);
BTW: I had a hard time reading even this single line. Consider indenting your code to make it human-readable. Also, I recommend against using variable substitution (the $siteurl var in your string) when you are using printf anyway. I mean, use the same mechanism to do the same thing. Either use only var substitution, or use only printf formattng, not both. Example:
$html = '
<a href="/r?%s"
target=_blank
onClick="window.open(location.href=%s/%s-%s.html)"
>
';
printf($html, $wurl, $siteurl, $myrow["wallpaperid"], $myrow["wallpapername"]);