if you start with the object style mysqli, you have to use it...can't switch between them...so your use of mysql_i_connect_error() won't ever return anything.
Aside from that, add in some debug to check for expected results:
<?php
function login($username, $password) {
$con = new mysqli("db_server.com", 'User', 'plain text password', 'whateverdb');
if ($con->connect_errno) {
die($con->connect_error);
}
$pass = md5($password);
$query = "SELECT * FROM user WHERE username = '$username' AND password = '$pass'";
if ($result = $mysqli->query($query)) {
if ($result->num_rows > 0) {
print "<pre>got the following results:\n\n";
while ($row = $result->fetch_assoc()) {
print_r($row);
}
} else {
print "no rows were returned!";
}
} else {
die($con->error);
}
}