How is my injection protection? What do I need to do to prevent injections?  In addition, if I have any statement/parameter errors, please tell me.

 &lt;?
 $username  = 'username';
 $pass      = 'pass';
 $cpass     = 'cpass';
 $email     = 'email';
 $gender    = 'gender';
 $firstname = 'firstname';
 $lastname  = 'lastname';
 $phone     = 'phone';
 $address   = 'address';

 $username    = htmlspecialchars($username, ENT_QUOTES);
 $pass        = htmlspecialchars($pass, ENT_QUOTES);
 $cpass       = htmlspecialchars($cpass, ENT_QUOTES);
 $email       = htmlspecialchars($email, ENT_QUOTES);
 $gender      = htmlspecialchars($gender, ENT_QUOTES);
 $firstname   = htmlspecialchars($firstname, ENT_QUOTES);
 $lastname    = htmlspecialchars($lastname, ENT_QUOTES);
 $phone       = htmlspecialchars($phone, ENT_QUOTES);
 $address     = htmlspecialchars($address, ENT_QUOTES);

 $uLength     = strlen($username);
 $pLength     = strlen($pass);
 $cpLength    = strlen($cpass);
 $emailLength = strlen($email);
 if ($uLength &gt;= 6 &amp;&amp; $uLength &lt;= 35) {

} else {

$errorMessage = $errorMessage . "Username must be between 6 and 35 characters" . "&lt;BR&gt;";

}
if ($emailLength &gt;= 3 &amp;&amp; $emailLength &lt;= 42) {

} else {

$errorMessage = $errorMessage . "Email must be between 3 and 42 characters" . "&lt;BR&gt;";

}

if ($pLength &gt;= 8 &amp;&amp; $pLength &lt;= 64) {

} else {

$errorMessage = $errorMessage . "Password must be between 8 and 64 characters" . "&lt;BR&gt;";

}
if ($cpLength &gt;= 8 &amp;&amp; $cpLength &lt;= 64) {

} else {

$errorMessage = $errorMessage . "Confirmation password must be between 8 and 64 characters" . "&lt;BR&gt;";
}
$user_name    = 'u904609109_dev';
$pass_word    = '_____';
$database     = 'u904609109_users';
$server       = 'mysql.2freehosting.com';

$con = mysqli_connect($server, $user_name, $pass_word, $database);
if (mysqli_connect_error()) {
    die('Connect Error: (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}

echo 'Connect Error:' . $mysqli-&gt;host_info . "\n";

$result = mysqli_query($con, $database);
if (!$result) {
    die("Failed to load " . mysqli_error($con));
}

$dblink = "SELECT * FROM users WHERE (username= '" . $username . "')";
$dblink-&gt;bind_param('username', $username);
if ($dblink) {
}

$result2  = mysqli_query($result, ($dblink));
$num_rows = mysqli_num_rows($result);

if ($num_rows &gt; 0) {

    $errorMessage = "Username already taken";

} else {
}
$dblink = $mysqli_query("SELECT * FROM users WHERE (email = '" . $email . "')");
$dblink-&gt;bind_param('username', $username);
if ($dblink) {
}
$result2  = mysqli_query($result, $dblink);
$num_rows = mysqli_num_rows($result);

if ($num_rows &gt; 0) {

    $errorMessage = "Email already taken";

} else {
}
$username = mysqli_real_escape_string($username);
$pass = mysqli_real_escape_string($pass);
$cpass = mysqli_real_escape_string($cpass);
$gender = mysqli_real_escape_string($gender);
$email = mysqli_real_escape_string($email);
$firstname = mysqli_real_escape_string($firstname);
$lastname = mysqli_real_escape_string($lastname);
$address = mysqli_real_escape_string($address);
$phone = mysqli_real_escape_string($phone);

$username= $_POST[($username)];
$pass= $_POST[($pass)];
$cpass= $_POST[($cpass)];
$gender= $_POST[($gender)];
$email= $_POST[($email)];
$firstname= $_POST[($firstname)];
$lastname= $_POST[($lastname)];
$address= $_POST[($address)];
$phone= $_POST[($phone)];

mysqli_select_db($database, $con);


$sql = "INSERT INTO users(username, pass, cpass, gender, email, firstname, lastname, address, phone) VALUES ('" . $username . "', '" . $pass . "', '" . $cpass . "', '" . $gender . "', '" . $email . "', '" . $firstname . "',  '" . $lastname . "', '" . $address . "', '" . $phone . "')";

$result1 = mysqli_query($con, $sql);
if (!$result1 || mysqli_query($con, $sql)) {
    die('Invalid query: ' . mysqli_error());
}
echo htmlentities($sql);

header("Location: finished.html"); {
    mysqli_close($con);
}
}
?&gt;
Give me parameterized SQL or give me death!
Seriously. Use prepared statements! Don't use mysqli_query as that makes your code vulnerable to SQL Injection. By using prepared statements, you won't need the mysqli_real_escape_string calls anymore.

This code looks nasty:
$result1 = mysqli_query($con, $sql);
if (!$result1 || mysqli_query($con, $sql)) {
    die('Invalid query: ' . mysqli_error());
}

First you perform the query. If the query fails (i.e. it returns a false-ish value), you die, but if the query works then you call the query again. And if the second query is successful, then you call die.
THAT MAKES NO SENSE!

This code can't possibly be working:
$dblink = &quot;SELECT * FROM users WHERE (username= '&quot; . $username . &quot;')&quot;;
$dblink-&gt;bind_param('username', $username);

And again, don't concatenate SQL queries! Use prepared statements!

Use better variable names!
What is $result1 and what is $result2? Describe what the result is for in the variable name.

You have a whole bunch of empty blocks, such as this:
if ($emailLength &gt;= 3 &amp;&amp; $emailLength &lt;= 42) {
    
} else {
    
$errorMessage = $errorMessage . &quot;Email must be between 3 and 42 characters&quot; . &quot;&lt;BR&gt;&quot;;
    
}

Also work on your indentation. Fixing the indentation, the if-logic and the string concatenation, and I suggest that you write your HTML tags with lowercase, this can be:
if ($emailLength &lt; 3 || $emailLength &gt; 42) {
    $errorMessage .= &quot;Email must be between 3 and 42 characters&lt;br&gt;&quot;;
}