A: 

Here is the way I normally use Mysqli

$mysqli = new mysqli($myServer, $myUser, $myPass, $myDB);
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
} 
$result = $mysqli->query($query);

while ($row=$result->fetch_assoc()) {
  print_r($row);
}

Note: mysqli is a class, $mysqli is the variable that holds the instance of that class, query is a method of that class that returns a result class that has methods of its own.

MindStalker
A: 

You are running all statements at once as far as php is concerned, so functions like affected rows or last inserted id will not work as expected. (Correct me if I'm wrong I haven't been using mysqli for a while.)

DCC
A: 

some of the mySqli functions needed some tinkering such as including $link

Taylor