connect_errno) { echo "Error: Failed to make a MySQL connection, here is why: \n"; echo "Errno: " . $mysqli->connect_errno . "\n"; echo "Error: " . $mysqli->connect_error . "\n"; exit; } $sql = "SELECT * from foobar"; if (!$result = $mysqli->query($sql)) { echo "Error: Our query failed to execute and here is why: \n"; echo "Query: " . $sql . "\n"; echo "Errno: " . $mysqli->errno . "\n"; echo "Error: " . $mysqli->error . "\n"; exit; } $row = $result->fetch_assoc(); printf("%s is %d\n", $row['name'], $row['value']); ?>