If you need the results of the query later on, you don't want to make the myvar variable hold osmething else. You may or may not need the results, just a mention.
If you do NOT need the results, try this:
<?php
$myvar = $wpdb->get_results("SELECT COUNT(*) FROM wp_visitorip WHERE ip='$user_ip'");
if($myvar == 0)
{
// no rows, do whatever.
}
else
{
// at least 1 row, do something else.
}
?>
If you do need the result of the query, do this instead.
$myvar = $wpdb->get_results("SELECT * FROM wp_visitorip WHERE ip='$user_ip'");
$myvarResults = mysql_num_rows($myvar);
if($myvarResults == 0)
{
// no rows, do whatever.
}
else
{
// at least 1 row, do something else.
// here you could run a while loop, whatever.
}
?>
There's tons of ways to do it. You can check the
myvar variable in tons of way.
Like, if (!is_array($myvar)),
do a num rows, do a count query, whatever.
Either way, if you do a check for = x, remember in a
check if something ='s a value, to use double equal signs,
($x == $y) or even triple in some cases.
When in doubt, php.net is a great reference for looking
up things you might not use everyday.