 <p>By the looks of a comment you left in another answer given (to the effect of getting the same error message), it sounds like you need to escape the entered data, including <code>if(!mysqli_query($con,$sql))</code> which is a contributing factor. - <em>See further down below.</em></p> <p>Using the following may very well fix the problem.</p> <pre><code>$con=mysqli_connect('localhost','root','root','secure_login'); // place this first if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $username = stripslashes($_POST['username']); $password = stripslashes($_POST['password']); $repassword = stripslashes($_POST['repassword']); $username = mysqli_real_escape_string($con,$_POST['username']); $password = mysqli_real_escape_string($con,$_POST['password']); $repassword = mysqli_real_escape_string($con,$_POST['repassword']); ... $sql = mysqli_query($con,"INSERT INTO users (username, password) VALUES ('".$username."','".$password."')"); ... </code></pre> <p>You also need to change:</p> <pre><code>if (!mysqli_query($con,$sql)){...} </code></pre> <p>to </p> <pre><code>if (!$sql){...} </code></pre> <p>you're querying twice with <code>mysqli_query</code> and connecting twice, which is a <strong>contributing</strong> factor, <em>then again</em>, it may very well be <strong>"thee"</strong> reason which I suspect it is.</p> <ul> <li>Consult <a href="http://stackoverflow.com/a/25268487/"><strong>this answer</strong></a> given by Marc B who states what is happening with a similar problem. His explanation will shed some light on the subject.</li> </ul> <hr> <p><strong>About password storage</strong></p> <p>I must also note that storing passwords in plain text is unsafe.</p> <p>You'd be better off using <a href="http://security.stackexchange.com/q/36471"><strong>CRYPT_BLOWFISH</strong></a> or PHP 5.5's <a href="http://www.php.net/manual/en/function.password-hash.php" rel="nofollow"><code>password_hash()</code></a> function. For PHP &lt; 5.5 use the <a href="https://github.com/ircmaxell/password_compat" rel="nofollow"><code>password_hash() compatibility pack</code></a> and use <a href="http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php" rel="nofollow"><strong>prepared statements</strong></a>.</p> <p>Plus as I stated in my comment;</p> <p>You don't need this <code>mysql_select_db("secure_login", $con);</code> for two reasons.</p> <p>1) <strong>You're already selecting a DB.</strong> <code>mysqli_connect('localhost','root','root','secure_login')</code> </p> <p>2) <strong>You're mixing MySQL APIs</strong> - Those are two different APIs, and they do not mix together.</p> <p>...and the fact about the missing quote for <code>$password</code> in <code>('$username',$password')</code></p>