How to fix Parse error: syntax error, unexpected 'else' (T_ELSE), expecting end of file : <p>This code provides this error Parse error: syntax error, unexpected 'else' (T_ELSE), expecting end of file. The code is probably terrible I have no clue what i am doing at all.</p>

<pre><code>I have tried altering the curly brackets but it still provides the same error

&lt;?php

$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "INSERT INTO posts (userid, artist, link) VALUES ('2', '".$_POST["artist"]."', '".$_POST["link"]."')";

if (mysqli_query($conn, $sql)); {
    echo "New record created successfully";


} else {
     echo "Error: " . $sql . "&lt;br&gt;" . mysqli_error($conn);
}

mysqli_close($conn);
?&gt;
</code></pre>
