Okay... very strange indeed.
Put aside your current script, and just test with this script, replacing the dummy connection and database settings:
mysql_connect("server", "username", "password")
OR die(mysql_error());
mysql_select_db("database")
OR die(mysql_error());
$sql = "SELECT `id`, `name`, `url` FROM `ads`
WHERE `batch` > 0 AND `amount` > `views` AND `type` = 'text'
ORDER BY RAND() LIMIT 3";
$result = mysql_query($sql)
OR die(mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
echo $row['name'];
}
} else {
echo 'No rows in result set';
}